posi90
Posts: 4
Joined: Sun Feb 03, 2013 11:53 am

RXTX - CommPortIdentifier

Sun Feb 03, 2013 12:19 pm

Hello,

I want java to connect to serial port. Minicom and GTKTerm already work, but i cant make java to connect.

Code: Select all

CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
throws

Code: Select all

gnu.io.NoSuchPortException
        at gnu.io.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:269)
        at main.connect(main.java:17)
        at main.main(main.java:131)

Code: Select all

CommPortIdentifier.getPortIdentifiers();
does not list any ports.

I cant explain why GTKTerm and Minicom work and java does not.

This is the tutorial i followed:http://eclipsesource.com/blogs/2012/10/ ... -and-rxtx/

Can anyone help me please?

KG
Poseidon

posi90
Posts: 4
Joined: Sun Feb 03, 2013 11:53 am

Re: RXTX - CommPortIdentifier

Sun Feb 03, 2013 12:21 pm

I'm sorry for double post!

User avatar
crackers
Posts: 55
Joined: Fri Dec 28, 2012 7:45 am

Re: RXTX - CommPortIdentifier

Sun Feb 03, 2013 7:29 pm

I stopped using RXTX on a Linux system a while back. I've really appreciated their efforts and used the heck out of it for years, but it got too hard to get that .so file loaded in the various environments I was trying out.

I recommend setting up ser2net on the Pi and using java.net.Socket to talk to it. Works like a charm.

posi90
Posts: 4
Joined: Sun Feb 03, 2013 11:53 am

Re: RXTX - CommPortIdentifier

Sun Feb 03, 2013 7:50 pm

Got it working now:

I just linked the port to another file like in this Post: http://pblog.ebaker.me.uk/2011/09/proce ... yacm0.html

Code: Select all

sudo ln -s /dev/ttyAMA0 /dev/ttyS80
Thank you very much =)

Pizerg
Posts: 5
Joined: Wed Nov 21, 2012 11:47 am

Re: RXTX - CommPortIdentifier

Mon Feb 04, 2013 11:58 am

Just add this line on the top of your code:

Code: Select all

System.setProperty("gnu.io.rxtx.SerialPorts", PORT_NAME);

kdekooter
Posts: 1
Joined: Wed Feb 06, 2013 1:14 pm

Re: RXTX - CommPortIdentifier

Wed Feb 06, 2013 1:29 pm

It is definitely a permissions issue.

On my pi the permissions for the port are:

Code: Select all

crw-rw---T  1 root dialout 188,   0 Feb  6 11:53 ttyUSB0
I changed the permissions:

Code: Select all

sudo chmod 666 /dev/ttyUSB0 
And now my java program runs fine.

-rst-
Posts: 1316
Joined: Thu Nov 01, 2012 12:12 pm
Location: Dublin, Ireland

Re: RXTX - CommPortIdentifier

Wed Feb 06, 2013 2:36 pm

kdekooter wrote:It is definitely a permissions issue.
...
I changed the permissions:

Code: Select all

sudo chmod 666 /dev/ttyUSB0 
And now my java program runs fine.
Maybe better to add the user (you plan to run the app as) to the dialup group?
http://raspberrycompote.blogspot.com/ - Low-level graphics and 'Coding Gold Dust'

neoro89
Posts: 3
Joined: Thu Feb 07, 2013 6:09 pm

Re: RXTX - CommPortIdentifier

Fri Feb 08, 2013 7:10 pm

posi90 wrote:Got it working now:

I just linked the port to another file like in this Post: http://pblog.ebaker.me.uk/2011/09/proce ... yacm0.html

Code: Select all

sudo ln -s /dev/ttyAMA0 /dev/ttyS80
Thank you very much =)
Hi posi90,

I'm also running into difficulties with this issue. However when I try your suggestion I get the following:

Code: Select all

RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyS80
Did you have similar issues or did it work fine first attempt?

Thanks.

billllyboy
Posts: 1
Joined: Fri Jan 17, 2014 2:34 pm

Re: RXTX - CommPortIdentifier

Fri Jan 17, 2014 2:42 pm

Hello,
sudo ln -s /dev/ttyAMA0 /dev/ttyS80
works but when I reboot the link disappear
It is possible to make it permanent?

Thanks

User avatar
DougieLawson
Posts: 37073
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: RXTX - CommPortIdentifier

Fri Jan 17, 2014 10:54 pm

billllyboy wrote:Hello,
sudo ln -s /dev/ttyAMA0 /dev/ttyS80
works but when I reboot the link disappear
It is possible to make it permanent?

Thanks
You'll need to write a udev rule /etc/udev/rules.d

I'll let you Google for the syntax.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jackdmarquez
Posts: 3
Joined: Thu Jun 05, 2014 8:55 pm

Re: RXTX - CommPortIdentifier

Thu Jun 05, 2014 8:59 pm

neoro89 wrote:
posi90 wrote:Got it working now:

I just linked the port to another file like in this Post: http://pblog.ebaker.me.uk/2011/09/proce ... yacm0.html

Code: Select all

sudo ln -s /dev/ttyAMA0 /dev/ttyS80
Thank you very much =)
Hi posi90,

I'm also running into difficulties with this issue. However when I try your suggestion I get the following:

Code: Select all

RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyS80
Did you have similar issues or did it work fine first attempt?

Thanks.

Did u fix that issue?? i'm getting the same.
Thanks

jackdmarquez
Posts: 3
Joined: Thu Jun 05, 2014 8:55 pm

Re: RXTX - CommPortIdentifier

Thu Jun 05, 2014 9:02 pm

Hi i am getting this issue

Code: Select all

RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyS80
Does anyone has fixed it??
Thanks.

Return to “Java”