BGS5 - same serial port for program upload and stdout? | Telit Cinterion IoT Developer Community
October 13, 2018 - 11:48am, 2109 views
Hi.
I am new to BGS5 modules, my last experience is with TC65. I have some problem with stdout.
I would like to use the same serial interface both for program upload (and run wia AT command) and for collecting System.out messages from my app. I would like to use ASC0, which is the interface used to connest my PC with BGS5. But when I try to setup "Userware/Stdout" to ASC0 I always get an ERROR message.
I there any way to setup my environment to use only ASC0?
Hello,
If System.out is redirected to an interface, it is not possible to execute any AT command on that interface. System.out should be activated from some other interface than the one being configured. It is possible to access the port from Java application and exchange data with some external device on the interface being used for System.out. However it is recommended that the device connected to the serial port only transmit data to the module because any application output will be mixed with System.out.
So you'd rather need more than one interface. You could try to use CommConnection instead of System.out to have a possibility to send AT commands before the application starts and after it exits or maybe you could try to redirect System.out from the application when it starts and stops.
Best regards,
Bartłomiej
Hello,
I guess that best solution to my broblems will be another interface used as System.out. I thought that I will be able to run my app with AT command on ASC0, and then using ASC0 as system out until application is running.
How can I redirect System.out from the application? Can it be done with AT commands in app? What will happen with System.out after application will be terminated abnormally?
Hello,
From the application you need to send the same AT command. There's API for sending AT commands from MIDlet. Then you should set it back to null in destroyApp() method which is called on application exit.
It is important for the application to leave startApp() method after initialization of the necessary components. The whole application code must NOT be placed into startApp() method because destroyApp() will not be called by the system if startApp() is still running.
If it happens for any reason that setting System.out port to null will fail, you will not regain the control over the port after the application stops. If you cut off the power while the application is running there will be no access to the port after reboot.
The other option would be to use CommConnection interface to output the application debug data. Then you should also take care to release the resources in destroyApp(). But in case of power outage you will have control after the power is back.
I don't know your scenario - as I understand form the context the app will not be running all the time but started by AT command (not autostart) and stopped.
Anyway the safest solution would be to have a separate interface for debug.
Best regards,
Bartłomiej