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

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

问题描述

我尝试将树莓派(带有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...

END EDIT

我编写了以下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" 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天全站免登陆