Java RXTXcomm lib to connect to /dev/ttyACM0 - java

I'm using RXXTX java lib to connect to serial ports. I'm using this lib with no problems connecting to /dev/ttyUSB0 (1,2,3,etc).
But when I want to connect to /dev/ttyACM0 the port its not found.
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier("/dev/ttyACM0");
the Exception is thrown:
gnu.io.NoSuchPortException
at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:218)
I already listed all the ports but no success.

Processing and USB ports /dev/ttyACM0, /dev/ttyACM1, ....
http://pblog.ebaker.me.uk/2011/09/processing-usb-ports-devttyacm0.html
Processing doesn't like reading Linux USB devices like /dev/ttyACM0 or
/dev/ttyACM1.
The solution is easy, just symlink the devices like this...
ln -s /dev/ttyACM[x] /dev/ttyS8[x]
You can put any number after the ttyS, although it is possible that
ttyS0 and other low numbers are defined, numbers in the eighties are
(almost) guaranteed to work.

This might help you: https://groups.google.com/forum/#!topic/openhab/f-gVkwJg-hg
update your startup script to include "->Dgnu.io.rxtx.SerialPorts=/dev/ttyACM0" in the Java command line

Related

Streamsets Error - Bad File Descriptor

I was attempting to use Streamsets to query an Oracle database and publish the data into Kafka. I downloaded Streamsets' tarball on my Mac and unzipped it into my home directory. Running $HOME/streamsets-datacollector-2.1.0.2/bin/streamsets dc started up on my first try, then I followed the instructions here to add the jdbc driver, then the instructions here to configure my streamsets job. However, I got an error: JDBC_00 - Cannot connect to specified database: com.streamsets.pipeline.api.StageException: JDBC_06 - Failed to initialize connection pool: java.sql.SQLRecoverableException: IO Error: Bad file descriptor.
This wound up having something to do with the limit on the number of files a process can have open. When I ran ulimit -n on the laptop, it showed 4864, then I set it to 10,000 via ulimit -n 10000, restarted the streamsets server, and it worked! If I need to keep running this, I will find a more procedural way of setting the ulimit for this process to work around this issue.
you definitely want need increase ulimit -n. To permanently change for all users in Ubuntu try the following:
echo "* soft nofile 60000" > /etc/security/limits.d/*_limits.conf && echo "* hard nofile 60000" >> /etc/security/limits.d/*_limits.conf
substitute 60000 with whatever number you want. I've never had a problem in streamsets using 60k. you should be able to do something similar in bsd.

Not able to connect Clamd server(Ubuntu) from java code

I'm trying to scan the Files for viruses using Clam Antivirus which is installed on Ubuntu on different machine from java code which is again on different machine. Below is my java code lines
//connect to Linux server
ClamScan clamScan = new ClamScan("127.0.0.1", 3310, 20);
// Scanning the test file
ScanResult result = clamScan.scan(new FileInputStream("D:\\vcredist_x64.png"));
I have done the necessary changes in Clamd.conf files that is to add the Tcp Port and Address , but still getting below error description
ERROR com.philvarner.clamavj.ClamScan - could not connect to clamd
server java.net.ConnectException: Connection refused: connect
So any body can help me to find out what is going wrong either in code or configuration .
Thanks in Advance.
Ali
Finally found the solution , actually clam daemon was not up and running .

Finding total file descriptors throws exception

I'm trying to find total file descriptors and found that sigar api allows to get those information. However while trying to do the below
Sigar sigar = new Sigar();
sigar.getProcFd(<pid>);
replaced the pid with an actual process if, throws the following exception:
org.hyperic.sigar.SigarNotImplementedException: This method has not been implemented on this platform
at org.hyperic.sigar.SigarNotImplementedException.<clinit>(SigarNotImplementedException.java:28)
at org.hyperic.sigar.ProcFd.gather(Native Method)
at org.hyperic.sigar.ProcFd.fetch(ProcFd.java:30)
at org.hyperic.sigar.Sigar.getProcFd(Sigar.java:531)
From the exception it's clear that the native Method - gather() hasn't been implemented/available on my OS (Mac OS X). How do I fix this? I tried adding the "libsigar-universal64-macosx.dylib" to the classpath but with no luck.
Also, I tried creating ProcFd like below instead of getting it from sigar:
ProcFd proc = new ProcFd();
System.out.println("Total FD: " + proc.getTotal());
In this case the output is always 0. Based on the api doc it looks like it should be providing the total number of open file descriptor (http://cpansearch.perl.org/src/DOUGM/hyperic-sigar-1.6.3-src/docs/javadoc/org/hyperic/sigar/ProcFd.html). Not sure if it's returning 0 because of the same reason as above i.e. missing implementation for my OS. Is that correct?
Also, wondering why is that when ProcFd is got using "sigar.getProcFd()" it throws the above mentioned exception. But when created using "ProcFd proc = new ProcFd()" it doesn't, however proc.getTotal() always returns 0?
I ended up using lsof in shell script instead of using sigar library. Never got this to work on mac. I tried in Linux and it worked without any issues.
The answer is in the documentation (http://cpansearch.perl.org/src/DOUGM/hyperic-sigar-1.6.3-src/docs/javadoc/org/hyperic/sigar/ProcFd.html), and as per your finding: OSX is not supported.
getTotal
public long getTotal()
Get the Total number of open file descriptors.
Supported Platforms: AIX, HPUX, Linux, Solaris, Win32.
System equivalent commands:
AIX: lsof
Darwin: lsof
FreeBSD: lsof
HPUX: lsof
Linux: lsof
Solaris: lsof
Win32:
Returns:
Total number of open file descriptors

Raspberry cant communicate with ACR122U

I dont know why appear this exception in the execution
javax.smartcardio.CardException: list() failed
at sun.security.smartcardio.PCSCTerminals.list(PCSCTerminals.java:126)
at javax.smartcardio.CardTerminals.list(CardTerminals.java:72)
at prueba.ClaseNFC.doCardReaderCommunication(ClaseNFC.java:41)
at prueba.Prueba.main(Prueba.java:20)
Caused by: sun.security.smartcardio.PCSCException: SCARD_E_NO_READERS_AVAILABLE
at sun.security.smartcardio.PCSC.SCardListReaders(Native Method)
at sun.security.smartcardio.PCSCTerminals.list(PCSCTerminals.java:80)
... 3 more
The code is:
TerminalFactory terminalFactory;
terminalFactory = TerminalFactory.getDefault();
System.out.println(terminalFactory);
List<CardTerminal> terminals = terminalFactory.terminals().list();
System.out.println("Terminals: " + terminals);
if (terminals.isEmpty()) {
throw new Exception("No card terminals available");
}
Its strange because the RPi recognize the card reader with the command "lsusb" where appear "Bus 001 Device 007: ID 072f:2200 Advanced Card Systems, Ltd".
I have been reading days ago and people talk about install the PC/SC Package from the page of ACR122U - http://www.acs.com.hk/en/products/3/acr122u-usb-nfc-reader/ - and it will solve the problem. Indeed, that package is useful to the amd64 and i386 architecture and the RPi has a ARM architecture with Raspbian (Debian/Linux).
My question is, could you help me in the way to install that package in a ARM architecture? or someway to solve my problem?
Thank you
If you have same issue this is the solution.
First time, you must install the ACR122 drivers. In this case, we hare using a Raspberry, so we must download the next driver: http://www.acs.com.hk/download-driver-unified/6258/ACS-Unified-Driver-Lnx-Mac-108-P.zip.
Unzip the file inside a folder, go to "acsccid-1.X.X" and run "./configure"
Open and edit raspi-blacklist.conf inside of "/etc/modprobe.d/" and add the next two lines at the end:
blacklist nfc
blacklist pn533
Reboot raspberry

JPOS Configuration Problems for an Epson POS printer in Windows

I'm trying to print using jPOS in Windows and get the following exception:
jpos.JposException: Could not connect to service with logicalName = Printer: Exception.message=jp.co.epson.uposcommon.util.EpsonJposServiceInstanceFactory
at jpos.loader.simple.SimpleServiceConnection.connect(Unknown Source)
at jpos.BaseJposControl.open(Unknown Source)
...
More information:
I'm trying to port our Java printing software from Linux (where it works well) to Windows. We are using an Epson TM-T70 receipt printer. I installed the regular printer drivers and was immediately able to print stuff using notepad, for instance.
Now I installed the Epson JavaPoS ADK. I configured the printer using the SetupPOS application that comes with the ADK. I created a new configuration for my printer with Logical Device Name "Printer". I saved everything and it created the jpos.xml file.
When I try run our application and it executes printer.open("Printer") where "Printer" is the logical device name and printer is a POSPrinter instance, I get the exception above.
I know that my generated jpos.xml file is being used because if I provide a random logical device name, I get a different exception.
I guess the problem is in the port configuration of SetupPOS. The printer is connected through USB. I tried the Port name that appears in the windows printer properties (ESDPRT001) and I even tried all combiniations of COM1 to COM10 but nothing works.
Does anyone have some suggestion? Thanks!
The Installation Routine of the Epson JavaPOS ADK is ... ahm ... let me say: "very special". So the Installation copies some jar files (like epsonupos.jar, jposXXX.jar and some more) in the ext/lib Directory of the JRE (!!!) (which must be selected while installing the JavaPOS Driver). We had also some very strange effects if we install another JavaPOS Version, switching to another JRE/JDK, using other Printers which are not from Epson or somthing else.
May be your problem is a result of any conflicts between different jar Version or JDK's or somthing else ...
EDIT:
Since ADK Version 1.11.anywhat (not realy sure, but I mean 1.11.9) you can specify the path in which the additional jar files are stored. But: Some DLL's will be also in the currently newest ADK Version (1.13.17) stored into the bin directory of the selected JRE. May be this is also a conflict between different Versions of used jar's and used DLLs or something else ...
I Solved this adding the following library paths to java project:
C:\Program Files\EPSON\JavaPOS\lib
C:\Program Files\EPSON\JavaPOS\SetupPOS
With javaPOS 1.14.6, on Debian 9 Linux I solved with LD_LIBRARY_PATH:
$ export LD_LIBRARY_PATH = /opt/EpsonJavaPOS/bin && javapos_application_to_run
On windows 10 copy:
BluetoothIO.DLL
epsonjpos.dll
EthernetIO31.DLL
SerialIO31.dll
USBIO31.DLL
from C:\Program Files\EPSON\JavaPOS\bin\
to C:\Program Files\Java\jre1.8.0.171\bin\
Run javaPOS application.
I know is a little late for response but may help others with similar problems.
In my case i am interacting with a Data logic Scanner using javapos, and i was having this message:
ERROR: Failed to open DL-Magellan-9400i-USB-OEM-Scanner-Scale profile, jpos.JposException: Could not connect to service with logicalName = DL-Magellan-9400i-USB-OEM-Scanner-Scale:
Exception.message=com.dls.jpos.service.DLSScannerInstanceFactory
i started looking in the javapos software that downloaded from datalogic and found that there was a jar file that was not included in my classpath (JavaPOS.jar) and that was why i was getting the error, take a look netx image:
I wanted to share in case someone has same issues.
(Took me almost 2 days to get it done!!)

Categories