Buongiorno a tutti ho eseguito un programma di supervisione in java.
Con la libreria jmodbus vado ad interrogare in wifi un plc S7-1200(protocollo modbus TCP).
Funziona tutto perfettamente.
Ho rifatto il programma adattandolo ad android. Legge e scrive il file nella sd, non da errori particolari nella comunicazione in senso che accetta e mi lascia implementare la libreria.
Quando provo a leggere però mi da eccezzione e mi restituisce un valore null.
es schematizzato:
codice:
ModbusTCPMaster modbus;
boolean ok;
int[] buff;
try
{
modbus=new ModbusTCPMaster("192.168.0.1",502);
}catch(Exception e)
{
Toast toast=Toast.makeText(this, e.getMessage(),Toast.LENGHT_SHORT);
toast.show(); //Nessuna segnalazione
}
try
{
buff=new int[2];
ok=modbus.readMultiRegisters(1,0,1,0,buff);
Toast toast=Toast.makeText(this, buff[0],Toast.LENGHT_SHORT);
toast.show(); //Questa funzione da pc restituisce il valore
}catch(Exception e)
{
Toast toast=Toast.makeText(this, e.getMessage(),Toast.LENGHT_SHORT);
toast.show(); //Da android restituisce null
}
Volevo capire se è la libreria non adatta ad android o se c'è qualche settaggio a fare all'htc.