Unknown error in "atServerIntegrationTest" due to specific API loading

Hi, I am testing legato applications in GL7605.
I try to install “atServerIntegrationTest” in legato-af and overwrite a new command.
I could get the unedited sample atServerIntegrationTest with reference to https://forum.mangoh.io/t/at-cmds-for-mirage-talon-from-mangoh-red-board-at-port/4803/15 .
I want to add an AT command and need the API with SIM information.
However, when I overwrote .adef and .cdef to add the API “le_sim.api”, a command is not working properly.
I would like you to investigate the cause of the problem.

More details are described below.

  • PC environment: Ubuntu 20.04.4 LTS 64 bit/ 5.15.0-46-generic
  • Product: GL7605 w/ WP7605 version SWI9X07Y_02.28.03.05 (from AT+GMR)
  • leaf version: 2.4.0 / swi-wp76_4.0.3
  • legato version: 19.02.0_4cb954265427b8c2c668a010ff5be274_modified
  • Settings:
>AT!ENTERCND=“A710”
>AT!USBCOMP=1,1,8014D
  • Error command:
$ ssh root@192.168.2.2
# app runProc atServerIntegrationTest --exe=atServerTest -- tty /dev/ttyHS0

If normal, during the execution of this command, UART will receive AT command input.
However, when I add the le_sim.api description, the command exits immediately after execution.
I tried with other APIs (e.g. le_antenna.api) and it works correctly.

  • Overwitten content:
  1. Component.cdef
api{
 atServices/le_atServer.api
 (my directory)/legato-af/interfaces/modemServices/le_mcc.api *
 (my directory)/legato-af/interfaces/modemServices/le_sim.api
}

*The sample code could not read le_mcc.api, so it is rewritten.

  1. atServerIntegrationTest.adef
bindings{
 atServerTest.atServerTestComp.le_atServer -> atService.le_atServer
 atServerTest.atServerTestComp.le_mcc -> atService.le_mcc
 atServerTest.atServerTestComp.le_sim -> atService.le_sim
}

you want to use UART or USB?

I saw you are configuring AT!USBCOMP but at the same time you are using /dev/ttyHS0

Thanks for your reply.
I have UART set up to recognize custom AT commands.
I am following https://forum.mangoh.io/t/at-cmds-for-mirage-talon-from-mangoh-red-board-at-port/4803/15.
In this forum, /dev/ttyHS0 which is equivalent to UART can receive AT commands while app runProc is running on USB.

it should be:


api:
{
        atServices/le_atServer.api
        le_mcc.api
        le_sim.api
}

bindings:
{
    atServerTest.atServerTestComp.le_atServer -> atService.le_atServer
    atServerTest.atServerTestComp.le_mcc -> modemService.le_mcc
    atServerTest.atServerTestComp.le_sim -> modemService.le_sim
}

If .api cannot be found during compilation, you can see here:

Thank you for your response, I solved the problem by changing the options in mkapp as follows.

mkapp -t wp76xx atServerIntegrationTest.adef -i ${LEGATO_ROOT}/interfaces/modemServices

I have another problem while writing the program, so let me ask you about it.
I am first trying to create an AT command, AT&P, with the equivalent functionality of AT+CNUM.
I use the le_sim_GetSubscriberPhoneNumber() function to get the SIM phone number, but the AT command port is frozen when I enter AT&P.
If the program is written incorrectly, please tell us how to write it correctly.

I write below in atServerTest.c.
I would like to display
“ID=PhoneNumber
OK”
No compilation errors have occurred.

void automaticTest_AtNumberHandler
(
    le_atServer_CmdRef_t commandRef,
    le_atServer_Type_t type,
    uint32_t parametersNumber,
    void* contextPtr
)
{

    int NumberLength = 11;
    char Number[LE_ATDEFS_RESPONSE_MAX_BYTES]; //phone number container
    char rsp1[LE_ATDEFS_RESPONSE_MAX_BYTES]; // display char
   memset(Number, 0, LE_ATDEFS_RESPONSE_MAX_BYTES); // All zero initialize 
   memset(rsp1, 0, LE_ATDEFS_RESPONSE_MAX_BYTES); // All zero initialize
    snprintf(rsp1, LE_ATDEFS_RESPONSE_MAX_BYTES, "ID="); // initial string

    PrepareHandler(commandRef, type, parametersNumber, contextPtr);
    LE_ASSERT(le_sim_GetSubscriberPhoneNumber(LE_SIM_EMBEDDED, Number, NumberLength) == LE_OK);
    snprintf(rsp1+strlen(rsp1), NumberLength, "%s", Number); // marge phone number
    LE_ASSERT(le_atServer_SendIntermediateResponse(commandRef, rsp1) == LE_OK); // display ID=Num

    LE_ASSERT(le_atServer_SendFinalResultCode(commandRef, LE_ATSERVER_OK, "", 0) == LE_OK); // OK

    return;
}

does it work for AT+KHTTPCFG if you are using the code here?

If it works, you can modify the code of +KHTTPCFG

I did not use it.
I download it from the URL and run AT+KHTTPCFG.
However, when I try to run the AT&P (I added), “app runProc …” is terminated.

have you tried to debug it?
which line is making the error?

If you put your code with le_sim_GetSubscriberPhoneNumber() function to Prepare_http_Handler() and trigger AT+KHTTPCFG, will it crash?

mkapp is running fine and not getting any error messages.
The AT+KHTTPCFG settings are also working fine, but still app runProc is terminated as soon as AT&P is executed.

Is there anything else I should rewrite besides Prepare_http_Handler()?

void automaticTest_AtNumberHandler
(
    le_atServer_CmdRef_t commandRef,
    le_atServer_Type_t type,
    uint32_t parametersNumber,
    void* contextPtr
)
{

    int NumberLength = 11;
    char Number[LE_ATDEFS_RESPONSE_MAX_BYTES]; //phone number container
    char rsp1[LE_ATDEFS_RESPONSE_MAX_BYTES]; // disply char
    memset(rsp1, 0, LE_ATDEFS_RESPONSE_MAX_BYTES); // All zero initialize
    snprintf(rsp1, LE_ATDEFS_RESPONSE_MAX_BYTES, "ID="); // initial string

    Prepare_http_Handler(commandRef, type, parametersNumber, contextPtr);
    LE_ASSERT(le_sim_GetSubscriberPhoneNumber(LE_SIM_EMBEDDED, Number, NumberLength) == LE_OK);
    snprintf(rsp1+strlen(rsp1), NumberLength, "%s", Number); // marge phone number
    LE_ASSERT(le_atServer_SendIntermediateResponse(commandRef, rsp1) == LE_OK); // display ID=Num

    LE_ASSERT(le_atServer_SendFinalResultCode(commandRef, LE_ATSERVER_OK, "", 0) == LE_OK); // OK

    return;
}

If you put your code with le_sim_GetSubscriberPhoneNumber() function to Prepare_http_Handler() and trigger AT+KHTTPCFG, will it crash?

This can isolate if your code has problem.
If no problem is found, that means your code on AT&P has problem

Or you can delete your code with le_sim_GetSubscriberPhoneNumber() function in automaticTest_AtNumberHandler() and see if the AT&P still trigger the crash.

I isolated the problem and AT&P without le_sim_GetSubscriberPhoneNumber() is running fine.
This is no different than before running AT+KHTTPCFG.

In summary, I guess the use of le_sim_GetSubscriberPhoneNumber() is preventing the app runProc from running.
I tried to create an AT command using le_sim_GetIMSI(), and app runProc terminated in the same way.
I think le_sim.api affects app runProc or there is a problem with the function loading way.
Is there any bug inthe function loading way in my program?

For le_sim_GetSubscriberPhoneNumber(), you can run this component and see if there is problem:

Also you can refer to the CM tool which uses the same API le_sim_GetSubscriberPhoneNumber():

For le_sim_GetIMSI(), you can refer to this modemdemo sample application:

Thanks for sharing many links.
After trying various settings, I noticed that the argument used for le_sim_GetSubscriberPhoneNumber() was set incorrectly with the information of the SIM being used.
By modifying as follows, the phone number was successfully output.

static le_sim_Id_t SimId = LE_SIM_EXTERNAL_SLOT_1;
LE_ASSERT(le_sim_GetSubscriberPhoneNumber(SimId, Number, sizeof(Number)) == LE_OK);

However, “app runProc” still crushes after executing “AT&P” command, and I cannot figure out why.
After adding the description about AT+KHTTPCFG, the following error statement appears at the time of crash.

$ ssh root@192.168.2.2
root@swi-mdm9x28-wp:~# app start atServerIntegrationTest
root@swi-mdm9x28-wp:~# app runProc atServerIntegrationTest --exe=atServerTest -- tty /dev/ttyHS0
PROCESS: 2213 ,TID 2213
SIGNAL: 11, ADDR (nil), AT (nil) SI_CODE 0x00000001
ILLEGAL ADDRESS (nil)
LEGATO VERSION
19.02.0_4cb954265427b8c2c668a010ff5be274_modified

PROCESS COMMAND LINE
atServerTest@0 tty /dev/ttyHS0 
PROCESS MAP
7f555000-7f556000 r-xp 00000000 ed:01 85315      /legato/apps/ad152a34190881e1112013e3aeb7de70/read-only/bin/atServerTest
7f566000-7f567000 r--p 00001000 ed:01 85315      /legato/apps/ad152a34190881e1112013e3aeb7de70/read-only/bin/atServerTest
7f567000-7f568000 rw-p 00002000 ed:01 85315      /legato/apps/ad152a34190881e1112013e3aeb7de70/read-only/bin/atServerTest
7f568000-7f5ae000 rw-p 00000000 00:00 0          [heap]
b6c5b000-b6d87000 r-xp 00000000 fe:00 835        /lib/libc-2.27.so

[…]

ffff0000-ffff1000 r-xp 00000000 00:00 0          [vectors]
BACKTRACE
PC at 00000000
LR at 00000000 [0xbe9c0634]
r0  00000000 r1  00000001 r2  b6ed68c0 r3  00000000 r4  00000000  r5  7f56a5a8
r6  00000000 r7  be9c0a30 r8  00000003 r9  b6ed6000 r10 7f567000 cpsr 60070010
fp  00000000 ip  00000000 sp  be9c09a8 lr  00000000 pc  00000000
STACK be9c09a8, FRAME 00000000
be9c0928: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000

[...]
Abort while dumping the stack
DONE
root@swi-mdm9x28-wp:~#

Do you know why it crashes?
Also, in the “atServerIntegrationTest”, are there any other APIs other than the ones quoted in the test file that are guaranteed to work?

Didn’t you can run the program by AT+KHTTPCFG?
If so, you can compare the routine of AT+KHTTPCFG and that of AT&P and figure out which line is making the crash, right?

For other command to try:


 AT+KHTTPCFG=0,"123.123.123.123",80,1    , you should see the following response:
*****
+KHTTPCFG PARAM 0: 0
+KHTTPCFG PARAM 1: 123.123.123.123
+KHTTPCFG PARAM 2: 80
+KHTTPCFG PARAM 3: 1

OK
*****


AT+KHTTPGET=0,"/index.php"    , you should see the following response:
*****
+KHTTPGET PARAM 0: 0
+KHTTPGET PARAM 1: /index.php
CONNECT
HTTP/1.1 200 OK
Date: Fri, 17 Jan 2020 09:38:13 GMT
Server: Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/5.6.26
X-Powered-By: PHP/5.6.26
Content-Length: 4
Content-Type: text/html; charset=UTF-8

test

OK
*****


type AT+KHTTPCLOSE=0    , you should see the following response:
*****
+KHTTPCLOSE PARAM 0: 0

OK

*****

Sorry, I tried the operation you suggested but it did not succeed.
I will share the file I am editing.
Would you please test the operation in the same environment?
Please replace the folder with the sample on Git “/legato-af/apps/test/atServices/atServerIntegrationTest/” and run it. (I deleted CMakeLists.txt by mistake, please add it.)

Below are the details of the operations I perform.

  1. Connect GL7605 with a miniSIM(in EXTERNAL_SLOT_1) to Ubunutu PC via USB (/dev/ttyUSB0,1,2)
  2. Set as follows
$ screen /dev/ttyUSB2
> AT!MAPUART=17,1
> AT!ENTERCND="A710"
> AT!USBCOMP=1,1,8014D
> AT!RESET
  1. Connect via SSH and run app runProc
$ ssh root@192.168.2.2
# app start atServerIntegrationTest
# app runProc atServerIntegrationTest --exe=atServerTest -- tty /dev/ttyHS0
(wait)
  1. Connect GL7605 to PC via UART and access /dev/ttyUSB3 from another terminal
  2. Set as follows
> ATE1
> AT+BRIDGE="OPEN"
> AT+BRIDGE="ADD"
> AT+KHTTPCFG=0,“116.66.221.43”,80,1
  1. Input AT&P
> AT&P
ID=***********
OK
  1. app runProc crashes and you can’t input AT commands

atServerIntegrationTest.zip (12.5 KB)

Your memset() has set wrong size for Number, that is why you see segmentation fault.
You should use this in your code:

static void automaticTest_AtNumberHandler
(
    le_atServer_CmdRef_t commandRef,
    le_atServer_Type_t type,
    uint32_t parametersNumber,
    void* contextPtr
)
{

#if 0
    char Number[LE_MDMDEFS_PHONE_NUM_MAX_BYTES]; //phone number container
    char rsp1[LE_ATDEFS_RESPONSE_MAX_BYTES]; // display char
    memset(Number, 0, LE_ATDEFS_RESPONSE_MAX_BYTES); // All zero initialize
    memset(rsp1, 0, LE_ATDEFS_RESPONSE_MAX_BYTES); // All zero initialize
    snprintf(rsp1, LE_ATDEFS_RESPONSE_MAX_BYTES, "ID="); // initial string
    static le_sim_Id_t SimId = LE_SIM_EXTERNAL_SLOT_1; // Container of Sim State

    // PrepareHandler(commandRef, type, parametersNumber, contextPtr);
    //Prepare_http_Handler(commandRef, type, parametersNumber, contextPtr);
    le_sim_GetSubscriberPhoneNumber(SimId, Number,  sizeof(Number));

    snprintf(rsp1+strlen(rsp1), sizeof(Number), "%s", Number); // marge phone number
    LE_ASSERT(le_atServer_SendIntermediateResponse(commandRef, rsp1) == LE_OK); // display ID=Num

    // LE_ASSERT(le_atServer_SendFinalResultCode(commandRef, LE_ATSERVER_OK, "", 0) == LE_OK); // OK
    LE_ASSERT(le_atServer_SendFinalResponse(commandRef, LE_ATSERVER_OK, false, "") == LE_OK);
#else


    char Number[LE_MDMDEFS_PHONE_NUM_MAX_BYTES]; //phone number container
        char rsp1[LE_ATDEFS_RESPONSE_MAX_BYTES]; // display char
        memset(Number, 0, LE_MDMDEFS_PHONE_NUM_MAX_BYTES); // All zero initialize
        memset(rsp1, 0, LE_ATDEFS_RESPONSE_MAX_BYTES); // All zero initialize
        snprintf(rsp1, LE_ATDEFS_RESPONSE_MAX_BYTES, "ID="); // initial string
        static le_sim_Id_t SimId = LE_SIM_EXTERNAL_SLOT_1; // Container of Sim State

        // PrepareHandler(commandRef, type, parametersNumber, contextPtr);
        //Prepare_http_Handler(commandRef, type, parametersNumber, contextPtr);
        le_sim_GetSubscriberPhoneNumber(SimId, Number,  sizeof(Number));

        snprintf(rsp1+strlen(rsp1), sizeof(Number), "%s", Number); // marge phone number
       LE_ASSERT(le_atServer_SendIntermediateResponse(commandRef, rsp1) == LE_OK); // display ID=Num



    PrepareHandler(commandRef, type, parametersNumber, contextPtr);
        // Send Final response
        LE_ASSERT(le_atServer_SendFinalResponse(commandRef, LE_ATSERVER_OK, false, "") == LE_OK);


#endif
    return;
}

Thank you for your debugging.
I had forgotten to change the memset() argument when I changed Number array.
AT&P now runs and exits successfully.