I want to have my App try periodically ping certain address (8.8.8.8 for example)to make sure my connection is fine. When I looked though documentation for legato all I can find is using ping via System() call. when I tried doing that as the example shows I always have a fail somewhere and if it does get to system call it always fails at the following ASSERT:
// Ping to test the connectivity
status = system(systemCmd);
if (WEXITSTATUS(status))
{
le_mdc_StopSession(profileRef);
}
LE_ASSERT(!WEXITSTATUS(status));
And the process is killed & restarted & then we go through the same process.
Have you tried to write socket program to send and reveive the ICMP packet?
This should be the same as ping command.
And you can search some ICMP sample code in Google easily.
Use a raw socket that will allow you to implement source selection a useful method is to use hop count to allow traceroute type functionality this was not hard to implement
Hi @mg_bg,
Can you try with sandboxed:true in .adef file of your application?
Because for me when i tried to use system command with sandboxed:false it was failing, But with sandboxed:true system command was working fine.
@muralinagraj I tried using it with sandboxed:true in adef but no luck. I mean it doesn’t fail but it doesn’t seem to do anything at all. I’m trying to run the following to rebbot the whole system:
char systemCmd[200] = {0};
int status;
snprintf(systemCmd, sizeof(systemCmd), "reboot");
status = system(systemCmd);
but the system never reboots at all.
Also according to the legato documentation, the sandboxed option is set to true by default so you do only need to set it when you want it to be false.