Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output parameters don't works #58

Closed
ksubileau opened this issue Apr 19, 2013 · 1 comment
Closed

Output parameters don't works #58

ksubileau opened this issue Apr 19, 2013 · 1 comment
Labels

Comments

@ksubileau
Copy link

Hi,
There are some problems with ouput arguments. If I write, for example :

String = autoclass('java.lang.String')
string = String("word".encode('utf-8'))
btarray= [0]*4
string.getBytes(0,4,btarray,0)
print btarray

It output :

[0, 0, 0, 0]

So the output argument(btarray) is not written
Same with :

[.....]
usbConnection = cast('android.hardware.usb.UsbDeviceConnection', UsbManager.openDevice(dev))
response= [0]*4
usbConnection.bulkTransfer(epIN, response, 4, 1000); # Try to read from USB (Host Mode API)
print response

If I use a bytearray (btarray=bytearray()), I get this error :

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/sdcard/testAn.py", line 13, in <module>
    string.getBytes(0,4,btarray,0)
  File "jnius_export_class.pxi", line 813, in jnius.jnius.JavaMultipleMethod.__call__ (jnius/jnius.c:17292)
JavaException: No methods matching your arguments

And if I use a list (btarray=list()), I get this :

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/sdcard/testAn.py", line 13, in <module>
    string.getBytes(0,4,btarray,0)
  File "jnius_export_class.pxi", line 819, in jnius.jnius.JavaMultipleMethod.__call__ (jnius/jnius.c:17414)
  File "jnius_export_class.pxi", line 577, in jnius.jnius.JavaMethod.__call__ (jnius/jnius.c:15021)
  File "jnius_export_class.pxi", line 658, in jnius.jnius.JavaMethod.call_method (jnius/jnius.c:15691)
  File "jnius_utils.pxi", line 39, in jnius.jnius.check_exception (jnius/jnius.c:2200)
JavaException: JVM exception occured

Thanks a lot.

@ksubileau
Copy link
Author

I suggest you to add this simple unit test that fails with the latest version available today :

tests/org/jnius/OutputParams.java :

package org.jnius;

public class OutputParams {
    public void sumarray(int[] intarray) {
        for (int i = 1; i<intarray.length; ++i) {
            intarray[0] += intarray[i];
        }
    }
}

tests/test_outputparams.py :

import unittest
from jnius import autoclass

OutputParams = autoclass("org/jnius/OutputParams");

class OutputParamsTest(unittest.TestCase):
    def test_outputparams(self):
        output = OutputParams()
        intarray = [1,4,5]
        output.sumarray(intarray)
        self.assertEqual(intarray[0], sum(intarray))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant