From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <3F6D0CC0-BB20-4A39-879F-9EE28589B53D@lbl.gov> On Dec 31, 2011, at 7:38 PM, Riley Porter wrote: > Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: > > if(XOFF : serialEventResponseLine){ > slowDown() > }; > > Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? > If you set XON/XOFF flow control, your code should _NOT_ see the XON/XOFF characters that your device sends. That should be handled by the operating system and RXTX together. Your worker thread just tries to send as fast as it can. That thread won't be given any processor time unless there's room to send more data. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From dcorbin at allureglobal.com Thu Dec 1 06:18:24 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 08:18:24 -0500 Subject: [Rxtx] Serial Port creation/initialization Message-ID: We've been using JavaComm libraries on Windows for years. We've recently added Linux support, and we had some problems with the IBM JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. When talking to a printer, our existing code is doing something like this: 1) Open the Serial Port 2) Send an Offline Query 3) Read Query Result 4) Send a Paper Out Query 5) Read Query Result 6) Send data to print 7) Close the serial device With RXTX, we're finding that we're getting back "random" results on the query reads. Sometimes we get offline indications and sometime we get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly. It's as if even though we have opened the port, it's not ready yet. The 1 second sleep would really suck as a solution, so I'm hoping someone can point me at a solution. Here is how we're opening the port: CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. Thanks for the help. -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From tjarvi at qbang.org Thu Dec 1 05:40:23 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 1 Dec 2011 05:40:23 -0700 (MST) Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, 1 Dec 2011, David Corbin wrote: > We've been using JavaComm libraries on Windows for years.? We've recently added Linux support, and we had some problems with the IBM > JavaComm implementation hanging, so we're looking at RXTX 2.1 on the Linux systems (probably for Windows eventually, but not yet). > > RXTX was relatively easy to put in place, and for the most part is working great, but we are having one odd problem. > > When talking to a printer, our existing code is doing something like this: > 1) Open the Serial Port > 2) Send an Offline Query > 3) Read Query Result > 4) Send a Paper Out Query > 5) Read Query Result > 6) Send data to print > 7) Close the serial device > > With RXTX, we're finding that we're getting back "random" results on the query reads.? Sometimes we get offline indications and sometime we > get out-of-paper indications when we both should be fine. If we add in a 1 second sleep between 1 & 2, everything functions smoothly.? It's > as if even though we have opened the port, it's not ready yet.? The 1 second sleep would really suck as a solution, so I'm hoping someone > can point me at a solution.? Here is how we're opening the port: > > ????? CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(portName); > ????? return new RxtxSerialPortDriver((SerialPort)portId.open("printer", timeout)); > > > This usage of the serial drivers all worked fine with the IBM/JavaComm, and on Windows with the Sun/JavaComm. > Hi David, You may try matching the timeout and threshold settings. We didnt have any defaults to go by from the documentation. -- Trent Jarvi tjarvi at qbang.org From dcorbin at allureglobal.com Thu Dec 1 07:54:42 2011 From: dcorbin at allureglobal.com (David Corbin) Date: Thu, 1 Dec 2011 09:54:42 -0500 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: > > > Hi David, > > You may try matching the timeout and threshold settings. We didnt have > any defaults to go by from the documentation. > > That did not have any effect. I also don't understand what the "threshold" is. It doesn't seem to be a standard RS-232 term/concept to me. > -- > Trent Jarvi > tjarvi at qbang.org > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- David Corbin Allure Global Solutions -------------- next part -------------- An HTML attachment was scrubbed... URL: From george.dma at gmail.com Thu Dec 1 08:19:09 2011 From: george.dma at gmail.com (George H) Date: Thu, 1 Dec 2011 17:19:09 +0200 Subject: [Rxtx] Serial Port creation/initialization In-Reply-To: References: Message-ID: Hi David, I am not sure we both have the same problem but this sleep thing is one thing that we had in common when I was accessing a printer on a parallel port. I remember a couple of years ago I chatted with someone about this, so I'm going to re-paste my explanation and solution of the bug I had. Hope it might shed some light on your issue. ---snip--- Yes I sort of fixed the problem. I don't know exactly what is at fault here (the rxtx driver or the parallel port). The problem was that the printer accepts some bytes then goes into a busy state. This is where we should be calling "isPrinterBusy()" in a loop and only send bytes when the printer is not busy. But rxtx always returns false. Seems to be dependent on some native parallel port driver. So what I did was find the code in rxtx C library where it sends bytes to the parallel port and added a loop. If the return value of the function "write" returns a negative value (meaning the write failed) we sleep for 1000 microseconds and try again. We loop only a maximum amount of times so that if there is a 100% failure rate the code exits after 60 seconds and throws an exception up to the rxtx java library. This fixed my problem because it seemed that the printer was busy but the rxtx library would not signal to me that it was busy so I had to make the code sleep every time the printer was busy. Only way I know the printer is busy is when a write byte fails to be sent. ---snip--- On Thu, Dec 1, 2011 at 4:54 PM, David Corbin wrote: > > > On Thu, Dec 1, 2011 at 7:40 AM, Trent Jarvi wrote: >> >> > > >> >> Hi David, >> >> You may try matching the timeout and threshold settings. ?We didnt have >> any defaults to go by from the documentation. >> > > That did not have any effect.? I also don't understand what the "threshold" > is. It doesn't seem to be a standard RS-232 term/concept to me. > > >> >> -- >> Trent Jarvi >> tjarvi at qbang.org >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> > > > > -- > David Corbin > Allure Global Solutions > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From v.alvidrez at gmail.com Thu Dec 8 09:29:32 2011 From: v.alvidrez at gmail.com (Victor Alvidrez) Date: Thu, 08 Dec 2011 09:29:32 -0700 Subject: [Rxtx] Link errors in JNI shared libraries, Linux. Message-ID: <4EE0E5EC.6060408@gmail.com> Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble getting the package to work under Linux (Ubuntu 11.04). There are two problems (that I know of). The first I was able to fix. It has to do with the check_kernel_headers function in the configure script. UTS_RELEASE is not defined in the header file linux/version.h and could not find it in any other header file. So I fixed this issue by replacing the existing "conftest.c" code with the following: """ #include #include #include int main(int argc, char *argv) { struct utsname name; uname(&name); printf("%s\n",name.release); exit(0); } """ Then I can run './configure' successfully. To get make to compile everything without complaint, I had to modify the CFLAGS variable in Makefile... added the UTS_RELEASE definition: CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE -D__need_timespec So now I can run 'make' without error. I wrote a simple test program that I could run directly from the source directory as follows: $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 However it produces these sorts of errors: """ Exception in thread "main" java.lang.UnsatisfiedLinkError: gnu.io.RXTXPort.Initialize()V at gnu.io.RXTXPort.Initialize(Native Method) at gnu.io.RXTXPort.(RXTXPort.java:55) at Test1.main(Test1.java:13) """ So after much head scratching and reading through the code I learned about the 'objdump' program. I print all the symbols using: $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so The only jni symbol that shows up is: Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner --- These are my versions: automake: 1.11.1 autoconf: 2.65 libtool: 2.2.6b ---- Do you have any idea of what I might be doing wrong? I can also provide make output or any other info as soon as I can. Thanks From tjarvi at qbang.org Thu Dec 8 17:25:53 2011 From: tjarvi at qbang.org (Trent Jarvi) Date: Thu, 8 Dec 2011 17:25:53 -0700 (MST) Subject: [Rxtx] Link errors in JNI shared libraries, Linux. In-Reply-To: <4EE0E5EC.6060408@gmail.com> References: <4EE0E5EC.6060408@gmail.com> Message-ID: On Thu, 8 Dec 2011, Victor Alvidrez wrote: > Hello. I downloaded the source package: rxtx-2.1-7r2. I am having trouble > getting the package to work under Linux (Ubuntu 11.04). > > There are two problems (that I know of). The first I was able to fix. It has > to do with the check_kernel_headers function in the configure script. > UTS_RELEASE is not defined in the header file linux/version.h and could not > find it in any other header file. So I fixed this issue by replacing the > existing "conftest.c" code with the following: > > """ > #include > #include > #include > > int main(int argc, char *argv) > { > struct utsname name; > uname(&name); > printf("%s\n",name.release); > exit(0); > } > > """ > > Then I can run './configure' successfully. To get make to compile everything > without complaint, I had to modify the CFLAGS variable in Makefile... added > the UTS_RELEASE definition: > CFLAGS = -D'UTS_RELEASE="2.6.32-30-generic"' -D_POSIX_SOURCE -D_BSD_SOURCE > -D__need_timespec > > So now I can run 'make' without error. > > I wrote a simple test program that I could run directly from the source > directory as follows: > $ java -Djava.library.path=x86_64-unknown-linux-gnu/.libs/ -cp . Test1 > > However it produces these sorts of errors: > """ > Exception in thread "main" java.lang.UnsatisfiedLinkError: > gnu.io.RXTXPort.Initialize()V > at gnu.io.RXTXPort.Initialize(Native Method) > at gnu.io.RXTXPort.(RXTXPort.java:55) > at Test1.main(Test1.java:13) > """ > > So after much head scratching and reading through the code I learned about > the 'objdump' program. > > I print all the symbols using: > $ objdump --syms x86_64-unknown-linux-gnu/.libs/librxtxSerial.so > > The only jni symbol that shows up is: > Java_gnu_io_CommPortIdentifier_native_1psmisc_1report_1owner > > --- > These are my versions: > automake: 1.11.1 > autoconf: 2.65 > libtool: 2.2.6b > ---- > > Do you have any idea of what I might be doing wrong? I can also provide make > output or any other info as soon as I can. > > Thanks _______________________________________________ Rxtx mailing list > Rxtx at qbang.org http://mailman.qbang.org/mailman/listinfo/rxtx > Hi Victor, report_owner is in fuserImp.c. It would appear that that object file was not linked in the final library. You could also checkout the updates from CVS which should build properly. -- Trent Jarvi tjarvi at qbang.org From rjobin at linuxtr.homelinux.net Fri Dec 9 16:44:17 2011 From: rjobin at linuxtr.homelinux.net (Richard Jobin) Date: Fri, 09 Dec 2011 18:44:17 -0500 Subject: [Rxtx] RXTX problem in Windows 7 Message-ID: <4EE29D51.1030503@linuxtr.homelinux.net> After many programs using RXTX under Linux and Windows XP without any problem, I wrote a new one in Linux and port it on Windows 7. On Linux, all is working as expected, but under Windows 7 it does not work. The problem, I can send data to the serial port without any problem, but I cant receive data from the serial port. To make it work under Windows 7, I use this trick. I have added a SerialPortListener and activate notify on data available. When the event fires, I send it to a method that read data. DataInputStream dis = new DataInputStream(InputStream is); wait for data like this: byte data; data = dis.readByte(); Like this, no problem, I received all data from the serial port. But, if I am using this kind of method, without using SerialPortEvent under Windows 7. while (true) { data = dis.readByte(); } I did not receive any data... Cannot explain this problem... It's not related to hardware flow control, I forced the RTS/CTS always asserted. Note: Same problem with real comport and USB-Serial adapter. Using Windows 7 32bits. From alfred.fuchs at t-online.de Sat Dec 10 04:41:10 2011 From: alfred.fuchs at t-online.de (Alfred Fuchs) Date: Sat, 10 Dec 2011 12:41:10 +0100 Subject: [Rxtx] RXTX problem in Windows 7 In-Reply-To: <4EE29D51.1030503@linuxtr.homelinux.net> References: <4EE29D51.1030503@linuxtr.homelinux.net> Message-ID: <4EE34556.3020709@t-online.de> Hi Richard, You have a 64-bit system? When "yes", it could be, that this behavior disappears if You apply the patches for 64-bit-systems I posted in august (they still are not applyed to the code, as i can see) On my Max-OSX (64 bit) now it runs stable. One of the reasons (i think) are the serious "castig"-bugs in rxtx: f.e.: in the "get_java_var" methode: a pointer in 64 bit is *greater than* size_t, so if the thread is moved in memory, suddenly the pointer is invalid: half of the bits are set to 0 ore something else. Best regards, Alfred On 12/10/2011 12:44 AM, Richard Jobin wrote: > After many programs using RXTX under Linux and Windows XP > without any problem, I wrote a new one in Linux and port it > on Windows 7. > On Linux, all is working as expected, but under Windows 7 > it does not work. > > The problem, I can send data to the serial port without any > problem, but I cant receive data from the serial port. > > To make it work under Windows 7, I use this trick. > > I have added a SerialPortListener and activate notify on > data available. When the event fires, I send it to a method > that read data. > > DataInputStream dis = new DataInputStream(InputStream is); > > wait for data like this: > > byte data; > data = dis.readByte(); > > Like this, no problem, I received all data from the serial port. > > But, if I am using this kind of method, without using > SerialPortEvent under Windows 7. > > while (true) { > data = dis.readByte(); > } > > I did not receive any data... Cannot explain this problem... > > It's not related to hardware flow control, I forced the RTS/CTS > always asserted. > > Note: Same problem with real comport and USB-Serial adapter. > Using Windows 7 32bits. > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > From bobyetman at verizon.net Sun Dec 11 05:37:29 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 07:37:29 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user Message-ID: <4EE4A409.3000600@verizon.net> I'm having the exact same problem as Richard with the Windows 7 RXTX library. I just switched from Linux to Windows (long story), and when I do the inputStream.read() it always returns a -1. NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's work-around. -- Bob Yetman KB3TWH From bobyetman at verizon.net Sun Dec 11 06:35:46 2011 From: bobyetman at verizon.net (Bob Yetman) Date: Sun, 11 Dec 2011 08:35:46 -0500 Subject: [Rxtx] RXTX Problem in Windows 7 - another user In-Reply-To: <4EE4A409.3000600@verizon.net> References: <4EE4A409.3000600@verizon.net> Message-ID: <4EE4B1B2.3070800@verizon.net> Okay, I know it's bad form to reply to your own message, but I figured out my problem. It wasn't the library, it was the device, I needed to call setRTS(true); and now I can read fine. On 12/11/11 7:37 AM, Bob Yetman wrote: > I'm having the exact same problem as Richard with the Windows 7 RXTX > library. I just switched from Linux to Windows (long story), and when I > do the inputStream.read() it always returns a -1. > > NOTE: This is on Windows 32 (not 64 bit). I haven't yet tried Richard's > work-around. > -- Bob Yetman KB3TWH From arigead at gmail.com Fri Dec 16 16:24:40 2011 From: arigead at gmail.com (Arigead) Date: Fri, 16 Dec 2011 23:24:40 +0000 Subject: [Rxtx] Two way communications with a serial port Message-ID: <4EEBD338.4090302@gmail.com> Hello all, just signed up here and firing of this message before lurking for a while, to get a feel for the place. I'll just chance my arm, fire of a question, and suffer the consequence. I'm not a Java programmer by nature but rather at the moment by necessity, as I'm wanting a piece of Hardware to interface to a nice little Java application. I'm usually an embedded programmer but every now and again you have to put your head above the parapet and smell fresh air ;-) So my HW is using serial comms and I want to talk to it. The protocol is command driven so the Java will fire off a command and sometimes expect a response and sometimes not. It depends on the command issued. I'm looking at the rxtx stuff, but can't seem to find a method which will tell me is there anything to read in the input stream. I really want to clear the input stream so that I can issue a command and read the response. I'd like to clear anything that's lingering on the stream. If I use read it'll block if there's nothing there to read. :-( I hope I'm explaining this in some sort of understandable way. Basically when I have a command to issue clear the inputStream if there's anything there to read. Now the inputStream is clear issue the command and read the response. rxtx uses java.io.InputStream which has an available method but the documentation at [1] but that reference states "A single read or skip of this many bytes will not block, but may read or skip fewer bytes." That sort of makes me uncertain if this is a good method to use. Thanks for any pointers to the correct direction. [1] http://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html#available() -------------- next part -------------- An HTML attachment was scrubbed... URL: From msemtd at googlemail.com Sun Dec 18 14:01:41 2011 From: msemtd at googlemail.com (Michael Erskine) Date: Sun, 18 Dec 2011 21:01:41 +0000 Subject: [Rxtx] Two way communications with a serial port In-Reply-To: <4EEBD338.4090302@gmail.com> References: <4EEBD338.4090302@gmail.com> Message-ID: I always use RXTX in the same way: have a serial event handler to read the bytes as they arrive. Otherwise you'll be repeatedly polling to see if there's anything to read and then reading it! The serial event handler will _tell_ you that there's something to read and then it can be read immediately in the handler. I have never had to use anything different (even in the years prior to RXTX using Sun JavaComm) as any other conceivable data handling scenario can be done in this way. From cheersgogo at yahoo.com.tw Mon Dec 19 21:01:01 2011 From: cheersgogo at yahoo.com.tw (謝悟鋒) Date: Tue, 20 Dec 2011 12:01:01 +0800 (CST) Subject: [Rxtx] keonn.mitchell Message-ID: <1324353661.85326.yint-ygo-j2me@web74206.mail.tp2.yahoo.com> How are you doing, my dear? http://eudriving.mireene.com/dir/gtnhkiuruki.php?usevaolID=12 Tue, 20 Dec 2011 5:01:00 ______________ "Ill bet Coras radio will radiate royally and right." (c) BRITT x9gaan From ricardomiguel.sn at gmail.com Mon Dec 26 04:04:48 2011 From: ricardomiguel.sn at gmail.com (Ricardo Nunes) Date: Mon, 26 Dec 2011 11:04:48 +0000 Subject: [Rxtx] Error on RXTX recompile Message-ID: I need to recompile rxtx-2.1-7r2 sources to x86 and x64 (in order to delete a usleep line of code). I'm trying to do it on VS2010. I've followed these steps: 1. Create a new DLL project; 2. Add jdk/include and jdk/include/win32 to the include path (jdk1.6.0_21) 3. Add SerialImpl.c, SerialImpl.h and SerialImpl.cpp to the project. When I try to build the project, I have one error, but all over the project (20 times): expression must have pointer type serialimp.c - (*env) -> ExceptionDescribe( env ); I guess this error appears a lot because env it's a JNIEnv* and and the definition of JNIEnv makes that type a struct, not a pointer. Could you help me with that error or with a new way to compile RXTX sources for Win x64 and x86 (in two separated dlls obviously)? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Mon Dec 26 04:52:44 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Mon, 26 Dec 2011 12:52:44 +0100 Subject: [Rxtx] Problem in the Windows 7 Message-ID: Hello, I'm using Rxtx library for communication with the star gazer device. I am reading data from the device successfully, but I have a problem with the data sending, I can't send anything. Does anyone have the same experience with the data sending? -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt.r.stevenson at gmail.com Tue Dec 27 16:21:02 2011 From: matt.r.stevenson at gmail.com (Matt Stevenson) Date: Tue, 27 Dec 2011 17:21:02 -0600 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: It could be timing out. Windows has default 16ms com port latency. This can be adjusted for each com port in the Device Manager properties. On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > Hello, > > I'm using Rxtx library for communication with the star gazer device. I am > reading data from the device successfully, but I have a problem with the > data sending, I can't send anything. Does anyone have the same experience > with the data sending? > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -- Matt Stevenson. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zordan.marko at gmail.com Wed Dec 28 01:27:24 2011 From: zordan.marko at gmail.com (Marko Susic) Date: Wed, 28 Dec 2011 09:27:24 +0100 Subject: [Rxtx] Problem in the Windows 7 In-Reply-To: References: Message-ID: Thanks Matt, I solved the problem with the sending :). I am sorry, the problem was in the device I communicate with. Device demands from sender to send byte by byte, and I didn't know that. Anyway, thanks a lot, library works grate :). On Wed, Dec 28, 2011 at 12:21 AM, Matt Stevenson wrote: > It could be timing out. Windows has default 16ms com port latency. > This can be adjusted for each com port in the Device Manager properties. > > On Mon, Dec 26, 2011 at 5:52 AM, Marko Susic wrote: > >> Hello, >> >> I'm using Rxtx library for communication with the star gazer device. I am >> reading data from the device successfully, but I have a problem with the >> data sending, I can't send anything. Does anyone have the same experience >> with the data sending? >> _______________________________________________ >> Rxtx mailing list >> Rxtx at qbang.org >> http://mailman.qbang.org/mailman/listinfo/rxtx >> >> > > > -- > Matt Stevenson. > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rileyporter at gmail.com Sat Dec 31 10:01:04 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 12:01:04 -0500 Subject: [Rxtx] XON / XOFF Question Message-ID: Hey guys, I am pretty new to using RXTX and was hoping I was missing something. My partner and I have created a CNC Gcode interpreter that uses the FTDI chipset for serial communication. We put software flow control (XON,XOFF) in place on the hardware it self. I see how to detect things like hardware flow control IE isCTS(); however I cannot find / figure out the equivalent isXON() etc. I have thought to try to parse the serial Data available event string to look for 0x13 but again not sure if this is connect. Any help would be great guys. Oh and our hardware project is here if you were interested. Thanks again, Riley -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kustaa.Nyholm at planmeca.com Sat Dec 31 11:08:00 2011 From: Kustaa.Nyholm at planmeca.com (Kustaa Nyholm) Date: Sat, 31 Dec 2011 20:08:00 +0200 Subject: [Rxtx] XON / XOFF Question In-Reply-To: Message-ID: On 12/31/11 19:01, "Riley Porter" wrote: >Hey guys, >I am pretty new to using RXTX and was hoping I was missing something. My >partner and I have created a CNC Gcode interpreter that uses the FTDI >chipset for serial communication. We put software flow control >(XON,XOFF) in place on the hardware it self. I see how to detect things >like hardware flow control IE isCTS(); however I cannot find / figure >out the equivalent isXON() etc. I have thought to try to parse the serial >Data available event string to look for 0x13 but again not sure if this >is connect. Any help would be great guys. > >Oh and our hardware project is here > if you >were interested. > > >Thanks again, > >Riley > Basically when you enable xon/xoff it is handled at driver level so you don't have to care at the host end (ie where you are running rxtx). I don't know how that is handled at the FTDI end, there you may have to send and listen to xon/xoff yourself or perhaps the chip does it. br Kusti From rileyporter at gmail.com Sat Dec 31 15:41:28 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 17:41:28 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Thanks, Riley On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm wrote: > On 12/31/11 19:01, "Riley Porter" wrote: > > >Hey guys, > >I am pretty new to using RXTX and was hoping I was missing something. My > >partner and I have created a CNC Gcode interpreter that uses the FTDI > >chipset for serial communication. We put software flow control > >(XON,XOFF) in place on the hardware it self. I see how to detect things > >like hardware flow control IE isCTS(); however I cannot find / figure > >out the equivalent isXON() etc. I have thought to try to parse the serial > >Data available event string to look for 0x13 but again not sure if this > >is connect. Any help would be great guys. > > > >Oh and our hardware project is here > > if you > >were interested. > > > > > >Thanks again, > > > >Riley > > > > Basically when you enable xon/xoff it is handled at driver > > level so you don't have to care at the host > end (ie where you are running rxtx). I don't know how > that is handled at the FTDI end, there you may have to > send and listen to xon/xoff yourself or perhaps the chip > does it. > > br Kusti > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 18:02:01 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 17:02:01 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. Bob -- Bob Jacobsen, LBNL Physics Division Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG From andy at g0poy.com Sat Dec 31 18:48:53 2011 From: andy at g0poy.com (Andy Eskelson) Date: Sun, 1 Jan 2012 01:48:53 +0000 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: <20120101014853.5916f727@workstation12> Xon-Xoff is a protocol, which should be sorted out by the system. You send data to your device, it takes in the data and fills it's buffer. If it's buffer starts filling up, your device sends an x-off character. To tell the sending system to stop for a while. after the buffer empties a bit, your system will send an x-on character which will start the data flow again. the same can happen in the other direction as well. X-on x-off is known as in-band flow control because it uses the actual data channel. It's not very good if you are sending binary data as things can get confused. With fast machines you may never see x-on x-off do anything as they can service the data flow faster than it is sent. One thing I will mention. You are controlling CNC machines, some CNC machines use hardware flow control, and sometimes use the hardware control lines to control things like nudging the table or the spindle. If your CNC is of this type, they sometimes don't work, or work rather badly with USB based RS232 converters. The polled nature of USB eats up a bit too much time for the control to happen correctly. this may not be a problem for you, but bear it in mind just in case. Andy On Sat, 31 Dec 2011 17:41:28 -0500 Riley Porter wrote: > Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON > is received? Perhaps I am missing a major point here :) > > Thanks, > > Riley > > On Sat, Dec 31, 2011 at 1:08 PM, Kustaa Nyholm > wrote: > > > On 12/31/11 19:01, "Riley Porter" wrote: > > > > >Hey guys, > > >I am pretty new to using RXTX and was hoping I was missing something. My > > >partner and I have created a CNC Gcode interpreter that uses the FTDI > > >chipset for serial communication. We put software flow control > > >(XON,XOFF) in place on the hardware it self. I see how to detect things > > >like hardware flow control IE isCTS(); however I cannot find / figure > > >out the equivalent isXON() etc. I have thought to try to parse the serial > > >Data available event string to look for 0x13 but again not sure if this > > >is connect. Any help would be great guys. > > > > > >Oh and our hardware project is here > > > if you > > >were interested. > > > > > > > > >Thanks again, > > > > > >Riley > > > > > > > Basically when you enable xon/xoff it is handled at driver > > > > level so you don't have to care at the host > > end (ie where you are running rxtx). I don't know how > > that is handled at the FTDI end, there you may have to > > send and listen to xon/xoff yourself or perhaps the chip > > does it. > > > > br Kusti > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > From gergg at cox.net Sat Dec 31 19:01:27 2011 From: gergg at cox.net (Gregg Wonderly) Date: Sat, 31 Dec 2011 20:01:27 -0600 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Good stuff Bob, some followup in line below: On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > >> Hmm.. So this is my use case.. I am sending a file line by line to the serial port. XON is "enabled" my board will send the XOFF when the buffer fills to a point. If my java program is for (line : file) { write(line) } how will "RXTX" know to pause the file sending routine until XON is received? Perhaps I am missing a major point here :) > > Usually this is handled by the same mechanism that holds your program up if you try to e.g. send 100,000 characters all at once: Your program is stopped until the data can be absorbed into the internal buffers between your program and the serial port. XON/XOFF is an operating system level control that allows no data to be lost because of buffer overflows. The handling needs to be as close to the "mechanical network" as possible, because the OS is the first layer of buffering which may be affected by flow control. The receiving OS needs to be able to say STOP if the application is not empty buffers fast enough, and the sending OS needs to be able to "stop the sending process" at the moment that more data would overflow the outbound buffers/hardware registers. > You should take this into account in designing your program. For example, if you try to send lots of data in a single operation from the Swing thread, your app may appear to be locked up while the XOFF/XON mechanism is metering the data out. On the other hand, if you only send little chunks of data, the buffering may handle it completely and there's no delay. For any operation, in Java, which is not related to directly manipulating some part of the GUI, you need to use some kind of background threading. The SwingWorker class is a workable solution for many types of applications. Some people hate it, but the basic delineation of responsibility between using the EventDispatchThread anytime you need to update the GUI, and dispatching background threads anytime a GUI event needs to talk to the "world", are handled. I have a more complex version of SwingWorker visible on http://swing-util.dev.java.net called "SyncThread". It allows you to dispatch multiple actions, and it includes management of the context class loader if you need that. Gregg Wonderly > Bob > -- > Bob Jacobsen, LBNL Physics Division > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx From rileyporter at gmail.com Sat Dec 31 20:38:32 2011 From: rileyporter at gmail.com (Riley Porter) Date: Sat, 31 Dec 2011 22:38:32 -0500 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: Message-ID: Thanks for all the great responses. I am aware of what has been said so far. However, perhaps I am not very clear in my real question. I am using a swing worker thread to send the file (line by line) to my device, which in turns WILL send an XOFF char. How is that character determined to be in fact sent from the serial device to my program? I fire serialEvents right now for data available. Should it be handled something like: if(XOFF : serialEventResponseLine){ slowDown() }; Something like that? Vs perhaps RXTX supplied a XON/XOFF serial event? Thanks again guys, Riley On Sat, Dec 31, 2011 at 9:01 PM, Gregg Wonderly wrote: > Good stuff Bob, some followup in line below: > > On Dec 31, 2011, at 7:02 PM, Bob Jacobsen wrote: > > > > > On Dec 31, 2011, at 2:41 PM, Riley Porter wrote: > > > >> Hmm.. So this is my use case.. I am sending a file line by line to the > serial port. XON is "enabled" my board will send the XOFF when the buffer > fills to a point. If my java program is for (line : file) { write(line) } > how will "RXTX" know to pause the file sending routine until XON is > received? Perhaps I am missing a major point here :) > > > > Usually this is handled by the same mechanism that holds your program up > if you try to e.g. send 100,000 characters all at once: Your program is > stopped until the data can be absorbed into the internal buffers between > your program and the serial port. > > XON/XOFF is an operating system level control that allows no data to be > lost because of buffer overflows. The handling needs to be as close to the > "mechanical network" as possible, because the OS is the first layer of > buffering which may be affected by flow control. The receiving OS needs to > be able to say STOP if the application is not empty buffers fast enough, > and the sending OS needs to be able to "stop the sending process" at the > moment that more data would overflow the outbound buffers/hardware > registers. > > > You should take this into account in designing your program. For > example, if you try to send lots of data in a single operation from the > Swing thread, your app may appear to be locked up while the XOFF/XON > mechanism is metering the data out. On the other hand, if you only send > little chunks of data, the buffering may handle it completely and there's > no delay. > > For any operation, in Java, which is not related to directly manipulating > some part of the GUI, you need to use some kind of background threading. > The SwingWorker class is a workable solution for many types of > applications. Some people hate it, but the basic delineation of > responsibility between using the EventDispatchThread anytime you need to > update the GUI, and dispatching background threads anytime a GUI event > needs to talk to the "world", are handled. > > I have a more complex version of SwingWorker visible on > http://swing-util.dev.java.net called "SyncThread". It allows you to > dispatch multiple actions, and it includes management of the context class > loader if you need that. > > Gregg Wonderly > > > Bob > > -- > > Bob Jacobsen, LBNL Physics Division > > Bob_Jacobsen at lbl.gov +1-510-486-7355 AIM, Skype JacobsenRG > > > > > > > > > > > > _______________________________________________ > > Rxtx mailing list > > Rxtx at qbang.org > > http://mailman.qbang.org/mailman/listinfo/rxtx > > _______________________________________________ > Rxtx mailing list > Rxtx at qbang.org > http://mailman.qbang.org/mailman/listinfo/rxtx > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob_jacobsen at lbl.gov Sat Dec 31 20:58:17 2011 From: bob_jacobsen at lbl.gov (Bob Jacobsen) Date: Sat, 31 Dec 2011 19:58:17 -0800 Subject: [Rxtx] XON / XOFF Question In-Reply-To: References: