I have a thermal printer that I am trying to configure with my Raspberry Pi 3b. I have a Wildfly server running a java app and I am trying to use this driver to communicate with the printer using the TSPL language.
Whenever I try to call connect I get an exception saying Permission denied: not enough privileges.
I tried to add a new permission in /lib/udev/rules.d
SUBSYSTEM=="usb", ATTR{idVendor}=="20d1", ATTR{idProduct}=="7001", MODE="0666", GROUP="wildfly"
And then run udevadm control --reload-rules to reload the rules but still no success.
I even tried to run:
sudo chown -R wildfly:wildfly /dev/usb/lp0
But still no success. Any help would be really appreciated at this moment. My printer is the HPRT LPQ58.
If I manually send commands to the /dev/usb/lp0 with the cat command those work, but with java I am not able to connect to the usb port.
Nevermind I found the problem. After a reboot it worked. It seems that
udevadm control --reload-rules
does not reload the rules if the printer is already plugged in the usb, so you either have to unplug and plug it back in or run:
udevadm control --reload-rules && udevadm trigger
Related
After launching the app in the emulator, I tried to locate the objects by uiautomateviewer, but when I tried to capture the screenshot it throws the error as
Error while obtaining UI hierarchy XML file:com.android.ddmlib.SyncException: Remote object doesn’t exist!.
I tied with the above steps like stopping the appium and tried to capture the sreen shot via UIautomatorviewer. But after stopping the appium server(Ctrl+C from command prompt) automatically the launched app in emulator gets terminated.
So because of this I can’t able to capture the screen shot and identify the obeject values.
Please help me to solve this issue.
Please try this :
kill the adb server and start it again.
sudo adb kill-server
sudo adb start-server
I have the following code fragment to show a HELLO WORLD by a USB Device (Display Posiflex PD-2800 for POS).
I use the GiovynetDrive library to manage a virtual COM port.
The code runs perfectly (assuming the COM3 is available).
SerialPort = new SerialPort();
Parameters settings = new Parameters();
settings.setPort("COM3");
settings.setBaudRate(Baud._19200);
Port = new Com(settings); //<<--Seting crash when restart
Port.sendString("HELLO WORLD");
Port.close();
My problem is that when I turn off the computer, it doesn't turn off the device (USB power). This cause that the next startup, the code throws the Exception:
java.lang.Exception: Error setting serial port COM3 state.
at giovynet.nativelink.SerialPort.openPortC(Native Method)
at giovynet.serial.Com.<init>(Com.java:48)
.........
This forces me to unplug and plug the USB device and then it works well again.
I think this behavior of the S.O. is configurable, but I don't know as.
UPDATE:
When the USB device is in the restart pending state, I can make a print test without problems using a text only printer (generic driver of the S.O.). Then I can see the print test by my viewer but from my java code still not working until I unplug it.
The S.O. is Windows XP and the USB root HUB (of the device management) have unabled the option "Allow the computer turn off the device to save energy".
Hey i would like to connect my eclipse programs written in Java with an Arduino. Previously i used Processing but now i am working on something more difficult: I will connect a Leap to an Arduino, but i get the following message when i try to connect to my port.
I am using a Mac and the port i used in processing was tty.usbserial-AM01VBFC
However this does not work with the given example from: http://playground.arduino.cc/interfacing/java
I changed this to match my port:
private static final String PORT_NAMES[] = {
"/dev/tty.usbserial-AM01VBFC", // Mac OS X
"/dev/ttyACM0", // Raspberry Pi
"/dev/ttyUSB0", // Linux
"COM3", // Windows
};
and the result is:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Could not find COM port.
Started
The port list is empty in my opinion because:
portEnum.hasMoreElements()
is false.
The full code can be found in the link above the only thing i changed is the port name for Mac OS X.
I have found only one guy with the same problem and he found a solution for ubuntu i do not understand: http://forum.arduino.cc/index.php?topic=73350.0;wap2
Hoping for some help,
Georgi
I found a solution for the problem:
System.setProperty("gnu.io.rxtx.SerialPorts", "/dev/tty.usbArduino");
the line above has to be commented out and you have to delete your lock files for a "fresh" USB connection!
Thanks to all the answers that lead me to the right way!
edit: it was "/dev/tty.usbArduino" because i made a symlink of my ports! I deleted the symlink afterwards
Follow Tim's advice and print the ports, running:
ls /dev/tty.*
in Terminal. This should allow you to double check if "/dev/tty.usbserial-AM01VBFC" is actually the correct name.
If nothing prefixed by tty.usbserial while your device is connected try this:
Install the FTDI VCP driver
Only if 1 doesn't work and you're using Mavericks try to unload Apple's FTDI driver: sudo kextunload -b com.apple.driver.AppleUSBFTDI (note that this need to be done once per OSX boot)
There are two types of cable:
Charging Cable
Data Transfer Cable
So, try changing cable if you have tried every usb driver and port.
Else, install driver using this link, http://www.wch.cn/download/CH341SER_MAC_ZIP.html
After installing if it doesn't work then change cable.
It worked for me after changing the cable.
I created a small web application.if i deployed its work but if try to run application it show
the port 8888 appears to be in use(perhaps by another lanch),do you still to contine with this lanch? i clicked yes
but show the error
Could not open the requested socket: Address already in use: bind
Try overriding --address and/or --port.
The problem is what it is stating.
You are facing this issue because of the following:
Either the port 8888 is in use by some other application and not previous launch. This is less likely.
This condition is more likely and it is because you have already launched the application once i.e. via the Run as Web Application. And it is still running. In your Eclipse, visit the Window-> Show View -> Console. And in the Console window, you will find one or more previous instances running. Please stop that.
There are some instances where the solution suggested by Romin will not work because the option to stop the process does not present itself in the console.
In these cases, you can probably find out which process ID is using the port and then kill that process.
For example, on a mac, this worked for me:
😈 >lsof -i tcp:8888
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 25866 alexryan 60u IPv6 0x96e9c26778f105e1 0t0 TCP localhost:ddi-tcp-1 (LISTEN)
😈 >kill 25866
😈 >lsof -i tcp:8888
😈 >
The port number 8888 is in use means that port already been activated. do one thing go to servicees option of control panel set the server start option from automatic to manual. Then your apps will get run. else you can stop the server from your eclipse env stop option.
I have a Java application which is running as non root mode.
My App will create a TFTP server (using apache commons tftp). TFTP server is bind to port 69(Default TFTP port). When running the app from IDE everything works fine since the IDE running as root. But if the app is run from other user i get the error
java.net.BindException: Permission denied
It is clear that for non root user i can not open the port. Is there a workaround for this issue?
For binding on Linux of ports less that 1024 you need to application to run a root. There is no way around this. If you need to do this you have you run as root. sudo might be the command to look into.
BTW - Running your IDE as root is not a very good idea.
To resolve this issue. You can use setuid() and setfid() system calls. So that you can temporarily elevate the permissions and then drop the permission back to user permissions.
In my Case, this problem happened in Solaris 11 OS. I added privileges to user to use the ports under 1024.
https://technicalsanctuary.wordpress.com/2014/06/03/allowing-a-user-to-use-ports-under-1024-on-solaris-11/