How to obtain answer's value from commands? through java code | Telit Cinterion IoT Developer Community
October 13, 2016 - 3:54pm, 10122 views
Hello
Im using this class (public class ATCommand) sucesfully.I can see answer from commands into console, but I would like to have access to this date through Java.
This is what I have:
answer=atc.send( new String(cmd) + 0x0D);
System.out.println(answer);
I got command and his answer on console.
This is the method
public String send(String ATCmd) throws ATCommandFailedException, IllegalStateException, IllegalArgumentException
- Parameters:
ATCmd
- The command to send.- Returns:
- The complete answer of the device corresponding to the send command.
- How to access to this "complete answer" through java code in ATCommand class isnt a method as getCommandAnswer, so how is posible ?
If you can see the whole answer in the log from SL libraries it means that you have done everything correctly.
Example:
[INFO] [DataExchangeDeviceGRIPConnection: MyDataExchangeDevice id] refreshStringValue: index: 1 value: AT^SCTM?
^SCTM: 1,0,28
OK
timestamp: 1072916383
Have you also tried with some other strings?
yes, I tried with other strings
[INFO] [DataExchangeDeviceGRIPConnection: MyDataExchangeDevice4 id] refreshStringValue: index: 0 value: at^SBV
^SBV: 4177
OK
timestamp: 1072925310
[INFO] [DataExchangeDeviceGRIPConnection: MyDataExchangeDevice4 id] refreshStringValue: index: 0 value: at^sctm?
^SCTM: 0,0,33
OK
timestamp: 1072925510
on INFO and displayed with System.out is posible to see complete answer but not in SL Command...
this is my DataExchangeUnitString instance:
**********************************************************************************
package pipe;
import com.gemalto.m2m.slagent.services.application.DataExchangeDeviceConfiguration;
import com.gemalto.m2m.slagent.services.application.DataExchangeException;
import com.gemalto.m2m.slagent.services.application.DataExchangeUnitString;
import pipe.ATService;
public class MyDataExchangeUnit4 extends DataExchangeUnitString {
ATService atService;
DataExchangeUnitString dataExchangeUnitString;
protected MyDataExchangeUnit4(String id, String label, boolean readOnly,DataExchangeDeviceConfiguration data_configuration) {
super(id, label, readOnly);
}
public String getValue() throws DataExchangeException {
String retorno;
retorno=ATService.getAnswer2();
return retorno;
}
protected void onValueChange(String arg0) throws DataExchangeException {
}
}
answer2=atc.send(new String(cmd)+0x0D);
public static String getAnswer2() {
return answer2;
}
public static void setAnswer2(String answer2) {
ATService.answer2 = answer2;
}
Cannot see where is the mistake...
If the SL library displays the complete answer there is no error in your code. If we are using the same libraries on the module it should work in the same way. How about the portal you are using - can you click the 'Options' then choose 'About' and paste the content?
Please also test with some other strings - for example some sentence without new line characters. And try to send some text from the portal (read only must be false in the client's code). Use a String object instead of At command reply and try to modify it from the platform.
so is strange.... this is wrote in About:
SL Management Portal
Version: SL_PORTAL_5.1.7.0
Deliver ID: SL_PORTAL_5_1_7_0_b0077_160525_1035
Copyright (c) 2006-2014 Gemalto
It's getting strange. I'm testing with exactly the same version of the portal. Are you sure that the communication of the device with the portal is really working? Can you find the messages on Reports tab after choosing STATUS Event Type?
I've got a feeling that we have checked everything, we have the same versions of libraries and are using the same version of portal and your implementation seems correct... I've sent you an email, you can send me back the project that reproduces this scenario. Then I would be able to try it with my account or maybe find something there.
thank you
how to send you the project ?, I dont have any mail in my email inbox.
I have sent again. Please check.
BR,
Bartłomiej
Hello,
I have run your app and the result is the same as you have described.
But I have solved the problem.
I have compared the string that your class sends with that I have used byte by byte and it seems that there is a '0' character (NULL) just after the command in your string. This character is treated as the end of the string in C and apparently it is also treated like that by the underlying protocol that is used to send the data to the platform or by the platform.
So removing '0' should help. I didn't try to debug why it was there.
Best regards,
Bartłomiej