Tengo que pasar 3 parametros de java a python, tengo entendido que si encuentra el file.py pero tiene un problema al momento de leer los datos:
Java -> Model.java
public void callPython(String user_ciclos, String temp_min, String temp_max)
{
interpreter = new PythonInterpreter();
interpreter.exec("from Arduino import sendData");
PyObject func = interpreter.get("sendData");
func.__call__(new PyString(user_ciclos), new PyString(temp_min), new PyString(temp_max));
}
Python -> Arduino.py
def sendData(ciclos, tem_m, temp_max):
print(ciclos, tem_m, temp_max)
'''
ardu= serial.Serial('COM4',9600, timeout=.1)
time.sleep(1)
ardu.write(ciclos.encode())
ardu.write(temp_m.encode())
ardu.write(temp_max.encode())
time.sleep(1)
'''
sendData(sys.argv[0],sys.argv[1],sys.argv[2])
Niveles de archivos:
Error en texto:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.python.core.PySystemState (file:/C:/Jython/jython.jar) to method java.io.Console.encoding()
WARNING: Please consider reporting this to the maintainers of org.python.core.PySystemState
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
console: Failed to install '': java.nio.charset.UnsupportedCharsetException: cp0.
Exception in thread "AWT-EventQueue-0" Traceback (most recent call last):
File "<string>", line 1, in <module>
File "__pyclasspath__/Arduino.py", line 24, in <module>
IndexError: index out of range: 1
Update:
Como uso el IDE Eclipse, es necesario cambiar el tipo de encodificación a UTF-8:
1.- Window
-> Preferences
2.- General
-> Workspace
-> Text File encoding