JavaME RaspBerryPi UART 无法从 RS485 接收数据 [英] JavaME RaspBerryPi UART can't receive data from RS485

查看:21
本文介绍了JavaME RaspBerryPi UART 无法从 RS485 接收数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试将我的 raspberry pi(带有 raspbian weezy)与条形 LED 模块连接起来.为此,我使用 RBPi 的 UART 连接来与 RS485 条形连接进行通信.

I try to connect my raspberry pi (with raspbian weezy) with a strip LED module. To do this, I use the UART connection of RBPi in order to communicate with RS485 strip connection.

我的问题:我可以(是的,我可以)发送数据,但我没有收到 ACK 或其他任何东西.然而,我的条形 LED 模块将数据帧发送到 RBPi(我可以在示波器上看到它).

My trouble : I can (yes I can) send data but I don't received ACK or anything else. However my strip LED module send data frame to the RBPi (I can see it on oscilloscope).

我认为这是由于程序打开UART连接时出现的以下错误.否:以下错误是由于非用户权限所致

I think it's due to the following error that appears when the program opened UART connection. NO : The following error is due to an non-user permission

[错误] [DAAPI] iso=-1: 无法打开/dev/mem

[ERROR] [DAAPI] iso=-1:cannot open /dev/mem

好吧,但我没有收到消息...

Well, But I don't receive message...

结束编辑

我编写了以下 javaME 代码来执行此操作:

I write the following javaME code to do this :

UARTConfig config = new UARTConfig((int)Integer.valueOf(this.getPortCom()),(int)Integer.valueOf(this.getPortCom()), this.getBaudrate(),
                                                this.getBitsperchar(), this.getUARTParity(), getStopBits(), UARTConfig.FLOWCONTROL_NONE);

this.uart = (UART)DeviceManager.open(config);

InputStream serialInputStream = Channels.newInputStream(uart);
BufferedReader serialBufferedReader = new BufferedReader(new InputStreamReader(serialInputStream));

 this.tSerialOutput = new Thread( new SerialWriter( Channels.newOutputStream(uart) ) );
 this.tSerialOutput.start();
 this.tSerialInput = new Thread( new SerialReader( serialBufferedReader ));
 this.tSerialInput.start();

this"是我管理串行通信的类.

"this" is my class which manage serial communication.

错误信息是在DeviceManager.open"之后得到的我已遵循以下票证的建议:https://community.oracle.com/message/12513726

The error message is getting after the "DeviceManager.open" I have follow the recommendation of the following ticket : https://community.oracle.com/message/12513726

但这并不是我问题的真正答案(我认为...)

But it's not really the answer of my issue (I think...)

我不知道......所以请帮帮我^^

I have no idea.... So please, help me ^^

推荐答案

首先,您必须确保 Linux 控制台尚未使用串行端口.以下是禁用此功能的方法:

First, you must be sure Serial Port is not already used by Linux Console. Here is how to disable this:

编辑 /etc/inittab 并通过在它前面添加一个 # 字符来禁用以下行

Edit /etc/inittab and disable the following line by adding a # character in front of it

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

然后重启.

如果这仍然不起作用,那么您可以尝试使用提升的权限执行 JavaME 运行时:

If this is still not working, then you may try to execute JavaME runtime with elevated privileges:

sudo ./runSuite.sh <yourapp>

如果这有效,则说明某处存在权限问题.

If this is working, there is a permission problem somewhere.

最后,您应该尝试获取最新版本的 JavaME(目前为 8.1).

Finally, you should try to get latest version of JavaME (currently, it is 8.1).

这篇关于JavaME RaspBerryPi UART 无法从 RS485 接收数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆