【转】解决linux下java读取串口之权限问题 No permission to creat

分享
出现这个问题主要是非root权限用户访问串口时出现。
在终端或IDE中运行java读取串口程序时,总是报告如下信息:


[lhwtouch@localhost root]$ java Main Experimental: JNI_OnLoad called. Stable Library ========================================= Native lib Version = RXTX-2.1-7 Java lib Version = RXTX-2.1-7 check_group_uucp(): error testing lock file creation Error detailsermission deniedcheck_lock_status: No permission to create lock file. please see: How can I use Lock Files with rxtx? in INSTALL


根据此提示,找到下载的RXTX包中的INSTALL文件后,用UE打开,发现如下信息【部分】:

Linux (only x86, x86_64, ia64 here but more in the ToyBox) RXTXcomm.jar goes in /jre/lib/ext (under java) librxtxSerial.so goes in /jre/lib/[machine type] (i386 for instance) Make sure the user is in group lock or uucp so lockfiles work. A person is added to group lock or uucp by editing /etc/groups. Distributions have various tools but this works: lock:x:54: becomes: lock:x:53:jarvi,taj Now jarvi and taj are in group lock. Also make sure jarvi and taj have read and write permissions on the port.


解决步骤为:

1:查找/etc下的groups文件,但是没有找到。只有group、group- 这2个文件,其中group文件就是我们要找的。

打开此文件,将如下2段修改:

uucp:x:14:uucp         修改为  uucp:x:14:uucp,lhwtouch

lock:x:54:                  修改为  lock:x:54:lhwtouch


修改这个文件后,必须重启系统,才能使之起效!


备注:

1、本人所用系统为中标普华linux2.6

2、修改group文件中的lhwtouch为系统的普通用户
短信设备二次开发 2022-04-09 0 0

admin

  • 注册时间 : 2022-03-30 04:08:47
  • 邮箱地址 : admin@tenghengkeji.com
  • 此页面用于展示用户的基本上资料信息

回帖 ( 0 )