0

I'm trying to write some hex data into /dev/ttyS1 from android java app without any success.

Easiest way should be to runtime exec command but it doesn't work for me.

I tried:

Process process = Runtime.getRuntime().exec("echo -n -e \\xb5\\x62\\x06\\x17\\x14\\x00\\x00\\x40\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x75\\x4f > /dev/ttyS1");

and also:

Process process = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(process.getOutputStream());
os.writeBytes("echo -n -e \\xb5\\x62\\x06\\x17\\x14\\x00\\x00\\x40\\x00\\x02\\x00\\x00\\x00\\x00\\x00\\x01\\x00\\x01\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x75\\x4f > /dev/ttyS1\n");
os.flush();
os.writeBytes("exit\n");
os.flush();

Without any success. The same commands from adb shell works of course.

Is there any other option to send hex data into /dev/ttyS1 from android app? Or maybe someone know what I'm doing wrong in my way?

I tried also method marked as answer in question How to make pipes work with Runtime.exec()? also without any luck.

Community
  • 1
  • 1
seek
  • 1,065
  • 16
  • 33
  • Possible duplicate of [How to make pipes work with Runtime.exec()?](http://stackoverflow.com/questions/5928225/how-to-make-pipes-work-with-runtime-exec) – OneCricketeer Mar 13 '17 at 07:02
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/137933/discussion-on-question-by-seek-writing-hex-data-into-dev-ttys1-on-android-java). – Bhargav Rao Mar 13 '17 at 11:16

0 Answers0