From allen at aemyers.com Tue Mar 6 18:18:27 2018 From: allen at aemyers.com (Allen Myers) Date: Tue, 6 Mar 2018 11:18:27 -0700 Subject: General Linux and Windows Library Usage Message-ID: I've been trying to find a reliable serial library to act as an interface to a USB connection to a UART on an Arduino. This Device I/O library looks brilliant. I'm just not sure if I can use it on a full Linux server (Dell server). Is this only designed to be run on embedded type platforms? Could it interface with a /dev/tty device on a standard Linux server? My production environment is Linux, but my test environment is Windows. If possible, how would I go about getting natives built for Windows? From bob.vandette at oracle.com Tue Mar 6 19:15:14 2018 From: bob.vandette at oracle.com (Bob Vandette) Date: Tue, 6 Mar 2018 14:15:14 -0500 Subject: General Linux and Windows Library Usage In-Reply-To: References: Message-ID: <6BD16C45-E352-477C-A300-1AAA595C706F@oracle.com> The Device I/O library only supports Linux. It should work on any Linux platform and not be restricted to embedded specific platforms as long as you configure it properly. I used the javax.comm package on Windows years ago but this support was EOL?d by Sun many years ago. I did a quick search and came up with this package that claims to do what you are looking for. I have no experience with this technology and this is not an endorsement of jSerialComm by Oracle. Use at your own risk. http://fazecast.github.io/jSerialComm/ Bob. > On Mar 6, 2018, at 1:18 PM, Allen Myers wrote: > > I've been trying to find a reliable serial library to act as an interface > to a USB connection to a UART on an Arduino. This Device I/O library looks > brilliant. I'm just not sure if I can use it on a full Linux server (Dell > server). Is this only designed to be run on embedded type platforms? Could > it interface with a /dev/tty device on a standard Linux server? > > My production environment is Linux, but my test environment is Windows. If > possible, how would I go about getting natives built for Windows? From allen at aemyers.com Tue Mar 6 20:22:06 2018 From: allen at aemyers.com (Allen Myers) Date: Tue, 6 Mar 2018 13:22:06 -0700 Subject: General Linux and Windows Library Usage In-Reply-To: <6BD16C45-E352-477C-A300-1AAA595C706F@oracle.com> References: <6BD16C45-E352-477C-A300-1AAA595C706F@oracle.com> Message-ID: Bob, ?Thank you for your input?! I'm actually attempting to use jSerialComm right now. However I seem to have some problems with how it manages threads. jSerialComm starts a separate thread to manage a listener for the native libraries it uses. But it doesn't seem to handle thread interruptions properly. https://github.com/Fazecast/jSerialComm/blob/master/src/ main/java/com/fazecast/jSerialComm/SerialPort.java#L1048 It also seems to have random Thread.sleep calls periodically in it's code base that I'm not sure underline a solid understanding of how to communicate with native libraries properly. Perhaps I'm still doing something wrong in my code, but I don't seem to be able to close a jSerialComm connection and then reopen it right after without it closing itself again shortly after for no apparent reason. Maybe I just need to accept I shouldn't close it. :) Or maybe I should change my development/test environment into a Linux platform and use Device I/O. :) This Device I/O library looks very well designed. I really want to use it, but I'm so entrenched in a Windows test environment right now, it's hard to give all that up for one library... On Tue, Mar 6, 2018 at 12:15 PM, Bob Vandette wrote: > The Device I/O library only supports Linux. It should work on any Linux > platform and not be restricted to embedded specific platforms as long as > you configure it properly. > > I used the javax.comm package on Windows years ago but > this support was EOL?d by Sun many years ago. > > I did a quick search and came up with this package that claims to do > what you are looking for. I have no experience with this technology and > this is not an endorsement of jSerialComm by Oracle. Use at your own risk. > > http://fazecast.github.io/jSerialComm/ > > Bob. > > > On Mar 6, 2018, at 1:18 PM, Allen Myers wrote: > > I've been trying to find a reliable serial library to act as an interface > to a USB connection to a UART on an Arduino. This Device I/O library looks > brilliant. I'm just not sure if I can use it on a full Linux server (Dell > server). Is this only designed to be run on embedded type platforms? Could > it interface with a /dev/tty device on a standard Linux server? > > My production environment is Linux, but my test environment is Windows. If > possible, how would I go about getting natives built for Windows? > > > From bob.vandette at oracle.com Tue Mar 6 20:47:19 2018 From: bob.vandette at oracle.com (Bob Vandette) Date: Tue, 6 Mar 2018 15:47:19 -0500 Subject: General Linux and Windows Library Usage In-Reply-To: References: <6BD16C45-E352-477C-A300-1AAA595C706F@oracle.com> Message-ID: <606B1AE5-0EF8-45C1-8D60-83A4C07954E2@oracle.com> > On Mar 6, 2018, at 3:22 PM, Allen Myers wrote: > > Bob, ?Thank you for your input?! > > I'm actually attempting to use jSerialComm right now. However I seem to > have some problems with how it manages threads. jSerialComm starts a > separate thread to manage a listener for the native libraries it uses. But > it doesn't seem to handle thread interruptions properly. > > https://github.com/Fazecast/jSerialComm/blob/master/src/ > main/java/com/fazecast/jSerialComm/SerialPort.java#L1048 > > It also seems to have random Thread.sleep calls periodically in it's code > base that I'm not sure underline a solid understanding of how to > communicate with native libraries properly. > > Perhaps I'm still doing something wrong in my code, but I don't seem to be > able to close a jSerialComm connection and then reopen it right after > without it closing itself again shortly after for no apparent reason. Maybe > I just need to accept I shouldn't close it. :) > As I stated, I have no experience with this library. Have you tried to use their examples? It looks like their default mode of operation is non blocking mode. This is why they require sleeps. It looks like you can open a serial port in blocking mode to avoid this issue. SerialPort comPort = SerialPort.getCommPorts()[0]; comPort.openPort(); comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING, 1000, 0); > Or maybe I should change my development/test environment into a Linux > platform and use Device I/O. :) This Device I/O library looks very well > designed. I really want to use it, but I'm so entrenched in a Windows test > environment right now, it's hard to give all that up for one library? Only you can decide if this is worth it. Bob. > > On Tue, Mar 6, 2018 at 12:15 PM, Bob Vandette > wrote: > >> The Device I/O library only supports Linux. It should work on any Linux >> platform and not be restricted to embedded specific platforms as long as >> you configure it properly. >> >> I used the javax.comm package on Windows years ago but >> this support was EOL?d by Sun many years ago. >> >> I did a quick search and came up with this package that claims to do >> what you are looking for. I have no experience with this technology and >> this is not an endorsement of jSerialComm by Oracle. Use at your own risk. >> >> http://fazecast.github.io/jSerialComm/ >> >> Bob. >> >> >> On Mar 6, 2018, at 1:18 PM, Allen Myers wrote: >> >> I've been trying to find a reliable serial library to act as an interface >> to a USB connection to a UART on an Arduino. This Device I/O library looks >> brilliant. I'm just not sure if I can use it on a full Linux server (Dell >> server). Is this only designed to be run on embedded type platforms? Could >> it interface with a /dev/tty device on a standard Linux server? >> >> My production environment is Linux, but my test environment is Windows. If >> possible, how would I go about getting natives built for Windows? >> >> >> From alexander.mironenko at oracle.com Tue Mar 6 22:51:14 2018 From: alexander.mironenko at oracle.com (Alexander Mironenko) Date: Tue, 6 Mar 2018 14:51:14 -0800 Subject: General Linux and Windows Library Usage In-Reply-To: References: Message-ID: Hi Allen, Device IO was designed and implemented to work on any Linux distribution, not only on embedded devices. Regarding the Windows? If you want to do that on Java, I think the only standard and tested approach is to use a JavaME Windows emulator that supports working with Windows COM port via generic connection framework. From the JavaSE, JNI is an approach for you as well. Also another approach is to use a some king of Linux emulator, to run Java SE on Linux. From my experience, there are some third-party Java libraries to work with COM ports on Windows, but usually the main problem of all those libraries is that many of them are not updated and supported a couple of years, because communication with COM ports on Windows is a kind of rare use case these days. Regards, Alex > On Mar 6, 2018, at 10:18 AM, Allen Myers wrote: > > I've been trying to find a reliable serial library to act as an interface > to a USB connection to a UART on an Arduino. This Device I/O library looks > brilliant. I'm just not sure if I can use it on a full Linux server (Dell > server). Is this only designed to be run on embedded type platforms? Could > it interface with a /dev/tty device on a standard Linux server? > > My production environment is Linux, but my test environment is Windows. If > possible, how would I go about getting natives built for Windows? From allen at aemyers.com Wed Mar 7 00:06:14 2018 From: allen at aemyers.com (Allen Myers) Date: Tue, 6 Mar 2018 17:06:14 -0700 Subject: General Linux and Windows Library Usage In-Reply-To: <606B1AE5-0EF8-45C1-8D60-83A4C07954E2@oracle.com> References: <6BD16C45-E352-477C-A300-1AAA595C706F@oracle.com> <606B1AE5-0EF8-45C1-8D60-83A4C07954E2@oracle.com> Message-ID: Bob, Your suggestion of looking closer at the blocking configuration was spot on and helped me to resolve my problem. Thank you. I wish jSerialComm would have propagated up the errno appropriately. Instead it swallows it and just returns a generic -1 and then throws a generic "port was closed" message in the Java library without any furthering information: https://github.com/Fazecast/jSerialComm/blob/master/src/main/c/Linux/SerialPort_Linux.c#L460-L470 I'm not sure why Windows didn't cause me a problem in non-blocking mode, but Linux apparently needs to be told it is okay to block with my implementation. I'm still wanting to use Device I/O after all this, so I may see if I can migrate to at least a virtual Linux machine to do remote debugging on for my test environment. Again, thank you so much! On Tue, Mar 6, 2018 at 1:47 PM, Bob Vandette wrote: > > On Mar 6, 2018, at 3:22 PM, Allen Myers wrote: > > Bob, ?Thank you for your input?! > > I'm actually attempting to use jSerialComm right now. However I seem to > have some problems with how it manages threads. jSerialComm starts a > separate thread to manage a listener for the native libraries it uses. But > it doesn't seem to handle thread interruptions properly. > > https://github.com/Fazecast/jSerialComm/blob/master/src/ > main/java/com/fazecast/jSerialComm/SerialPort.java#L1048 > > It also seems to have random Thread.sleep calls periodically in it's code > base that I'm not sure underline a solid understanding of how to > communicate with native libraries properly. > > Perhaps I'm still doing something wrong in my code, but I don't seem to be > able to close a jSerialComm connection and then reopen it right after > without it closing itself again shortly after for no apparent reason. Maybe > I just need to accept I shouldn't close it. :) > > > As I stated, I have no experience with this library. Have you tried to > use their > examples? It looks like their default mode of operation is non blocking > mode. This is why they require sleeps. It looks like you can open a > serial > port in blocking mode to avoid this issue. > > SerialPort comPort = SerialPort.getCommPorts()[0]; > comPort.openPort(); > comPort.setComPortTimeouts(SerialPort.TIMEOUT_READ_BLOCKING, 1000, 0); > > > Or maybe I should change my development/test environment into a Linux > platform and use Device I/O. :) This Device I/O library looks very well > designed. I really want to use it, but I'm so entrenched in a Windows test > environment right now, it's hard to give all that up for one library? > > > Only you can decide if this is worth it. > > Bob. > > > On Tue, Mar 6, 2018 at 12:15 PM, Bob Vandette > wrote: > > The Device I/O library only supports Linux. It should work on any Linux > platform and not be restricted to embedded specific platforms as long as > you configure it properly. > > I used the javax.comm package on Windows years ago but > this support was EOL?d by Sun many years ago. > > I did a quick search and came up with this package that claims to do > what you are looking for. I have no experience with this technology and > this is not an endorsement of jSerialComm by Oracle. Use at your own risk. > > http://fazecast.github.io/jSerialComm/ > > Bob. > > > On Mar 6, 2018, at 1:18 PM, Allen Myers wrote: > > I've been trying to find a reliable serial library to act as an interface > to a USB connection to a UART on an Arduino. This Device I/O library looks > brilliant. I'm just not sure if I can use it on a full Linux server (Dell > server). Is this only designed to be run on embedded type platforms? Could > it interface with a /dev/tty device on a standard Linux server? > > My production environment is Linux, but my test environment is Windows. If > possible, how would I go about getting natives built for Windows? > > > > > From allen at aemyers.com Wed Mar 7 00:11:57 2018 From: allen at aemyers.com (Allen Myers) Date: Tue, 6 Mar 2018 17:11:57 -0700 Subject: General Linux and Windows Library Usage In-Reply-To: References: Message-ID: Alexander, Thank you for your input also. I'm going to investigate further on running a Linux VM on my Windows test environment. To be honest, not having identical development and production environments has bothered me for a bit now. I know what you mean about using Windows to interact with serial ports. Most of the maker/DIY community seems to be very Linux driven in many aspects. I still would figure my desires of cross-platform support for a generic USB serial library wouldn't be so far fetched. But I guess I'm wrong. On Tue, Mar 6, 2018 at 3:51 PM, Alexander Mironenko < alexander.mironenko at oracle.com> wrote: > Hi Allen, > > Device IO was designed and implemented to work on any Linux distribution, > not only on embedded devices. > > Regarding the Windows? If you want to do that on Java, I think the only > standard and tested approach is to use a JavaME Windows emulator that > supports working with Windows COM port via generic connection framework. > From the JavaSE, JNI is an approach for you as well. > Also another approach is to use a some king of Linux emulator, to run Java > SE on Linux. > > From my experience, there are some third-party Java libraries to work with > COM ports on Windows, but usually the main problem of all those libraries > is that many of them are not updated and supported a couple of years, > because communication with COM ports on Windows is a kind of rare use case > these days. > > Regards, > Alex > > > On Mar 6, 2018, at 10:18 AM, Allen Myers wrote: > > > > I've been trying to find a reliable serial library to act as an interface > > to a USB connection to a UART on an Arduino. This Device I/O library > looks > > brilliant. I'm just not sure if I can use it on a full Linux server (Dell > > server). Is this only designed to be run on embedded type platforms? > Could > > it interface with a /dev/tty device on a standard Linux server? > > > > My production environment is Linux, but my test environment is Windows. > If > > possible, how would I go about getting natives built for Windows? > > From snazarkin at azul.com Wed Mar 7 08:46:51 2018 From: snazarkin at azul.com (Sergey Nazarkin) Date: Wed, 7 Mar 2018 08:46:51 +0000 Subject: General Linux and Windows Library Usage In-Reply-To: References: Message-ID: <2B01D562-CC69-4F23-864E-6FFB94DAC989@azul.com> Hi Allen, according to this link https://blogs.msdn.microsoft.com/wsl/2017/04/14/serial-support-on-the-windows-subsystem-for-linux/ WSL supports serial port passthrough. I?ve not tested but you may try OJDK for Linux with DIO running on Windows 10. Sergey Nazarkin > On 6 Mar 2018, at 21:18, Allen Myers wrote: > > I've been trying to find a reliable serial library to act as an interface > to a USB connection to a UART on an Arduino. This Device I/O library looks > brilliant. I'm just not sure if I can use it on a full Linux server (Dell > server). Is this only designed to be run on embedded type platforms? Could > it interface with a /dev/tty device on a standard Linux server? > > My production environment is Linux, but my test environment is Windows. If > possible, how would I go about getting natives built for Windows?