JavaME RaspBerryPi UART can't receive data from RS485

天大地大妈咪最大 提交于 2019-12-12 10:19:37

问题


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.

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).

EDIT :

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

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

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

END EDIT

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.

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 ^^


回答1:


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

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

then reboot.

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.

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



来源:https://stackoverflow.com/questions/27859419/javame-raspberrypi-uart-cant-receive-data-from-rs485

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!