1

I'd like to be able to access serial port from within monkeyrunner script. I've got separate python script that talks via rs232 to a device, and I've got a monkeyrunner script that drives an Android smartphone.

Now. After implementing the python script inside my monkeyrunner script and adding a specific path to the python serial module, the script reutrns the following error msg:

121219 10:40:51.630:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions] Script terminated due to an exception
121219 10:40:51.630:S [main] [com.android.monkeyrunner.MonkeyRunnerOptions]Traceback (most recent call last):
  File "C:\Android\android-sdk\tools\serial_test.py", line 13, in <module>
    import serial
  File "c:\Python27\Lib\site-packages\serial\__init__.py", line 23, in <module>
    from serialjava import *
  File "c:\Python27\Lib\site-packages\serial\serialjava.py", line 35, in <module>
    comm = detect_java_comm([
  File "c:\Python27\Lib\site-packages\serial\serialjava.py", line 29, in detect_java_comm
    raise ImportError("No Java Communications API implementation found")
ImportError: No Java Communications API implementation found

serial_test.py:

import sys
sys.path.append("c:\\Python27\\Lib\\site-packages")
import serial

Google pointed to a number of websites :

From: Java Comm API Package download through : http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-misc-419423.html to: http://mho.republika.pl/java/comm/

I've dowlnoaded and installed JavaComm from http://code.google.com/p/smslib/downloads/list

I also tried http://rxtx.qbang.org/wiki/index.php/Using_RXTX

But none of the sites actually had library that simply worked. Unless I messed up the installation but I find it hard to believe as it's just a matter of copying the files (apparently). From what I understand the Java Comms API package is now obsolete and not supported any more. There is contradicting info on the official Oracle FAQ. You can download java_comm_api-30u1-linux.zip and inside you'll find readme saying "We do not provide a linux implementation.

So here's the question: how can I use serial port inside monkeyrunner script ? Where can I find a simple example of using serial port in monkeyrunner/jython ?

Community
  • 1
  • 1
Jakub Czaplicki
  • 1,787
  • 2
  • 28
  • 50
  • So if you have a script that uses the serial port already make it take some parameters if needed and run it from your monkeyrunner script (i.e. using subprocess) – Diego Torres Milano Dec 20 '12 at 05:41
  • That's what I sort of did. I've written a socket server that talks to the serial port, and monkeyrunner sends commands to that server. – Jakub Czaplicki Dec 20 '12 at 09:39
  • I have the exact same problem. I guess I am just going to use subprocess from within my monkeyrunner script to run my other script that can use `serial` module using CPython. – Ankur Agarwal Mar 07 '17 at 03:28

0 Answers0