AT Component Source Code Parsing

RT-Thread IoT OS
12 min readMar 23, 2022

--

Introduction to AT Components

The core processing logic of the AT component is to put the received reply information of AT Component into a ring buffer, then read one row of data (“rn”) from this ring buffer for processing, to determine the types of message, and call different functions.

Taking the EC200x module from Quectel as an example, this article detailed parsing the implementation process of the AT components and the call logic of the code, looking to help developers quickly locate the problems if they’re encountering the same problems in the process of using AT components.

1.1 AT Component Debug Information Level Setting

You can control ON/OFF the DEBUG log function of the AT component by modifying the following in the RT-Thread Env tool, and you’ll see the relevant logs of debug level after enabling the debug log. Enabling this option will generate a #define AT_DEBUG in rtconfig.h, to control the AT component log-level is available on the rt-thread/components/net/at/include/at_log.h file.

1RT-Thread Components
2 -> Network
3 -> AT commands
4 -> [*] Enable debug log output /* Checked on- indicates that the modification log level is debug */

Note that after enabling the above features, the ec200x thread will notify a stack overflow (created by the ec200x_netdev_check_link_status() function in the packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c file) , spending about 1598Bytes stack space, and it is recommended to change the macro EC200X_LINK_THREAD_STACK_SIZE of ec200x_netdev_check_link_status() to 1024 +1024, which is in a total of 2048 bytes, to resolve stack overflow.

1.2 AT Command of Print Settings

When debugging, you have the control to enable the display of AT commands sent and received by the AT component by modifying the following in RT-Thread Env Tool, and you can see the executed AT commands and the execution results returned after enabling.

1RT-Thread Components
2 -> Network
3 -> AT commands
4 -> [*] Enable print RAW format AT command communication data /* Check on the AT commands that indicates the print is executing

When the above options are checked, an example of AT commands printed is as follows when performing the test

1[D/AT] recvline: 0000-0020: 41 54 0D 0D 0A                                          AT...
2[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
3[D/AT] sendline: 0000-0020: 41 54 45 30 ATE0
4[D/AT] recvline: 0000-0020: 41 54 45 30 0D 0D 0A ATE0...
5[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
6[D/AT] sendline: 0000-0020: 41 54 2B 49 50 52 3F AT+IPR?
701-01 00:40:19 D/at.clnt: execute command (AT+IPR?) timeout (300 ticks)!
8[D/AT] recvline: 0000-0020: 0D 0A ..
9[D/AT] recvline: 0000-0020: 2B 49 50 52 3A 20 31 31 35 32 30 30 0D 0A +IPR: 115200..
10[D/AT] recvline: 0000-0020: 0D 0A ..
11[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
12[D/AT] recvline: 0000-0020: 0D 0A ..
13[D/AT] recvline: 0000-0020: 52 44 59 0D 0A RDY..
1401-01 00:40:22 I/at.dev.ec200x: ec200x device initialize retry...
15[D/AT] sendline: 0000-0020: 41 54 45 30 ATE0
1601-01 00:40:24 D/at.clnt: execute command (ATE0) timeout (300 ticks)!
17[D/AT] recvline: 0000-0020: 0D 0A ..
18[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
19[D/AT] recvline: 0000-0020: 0D 0A ..
20[D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK..
21

1.3 GPRS Network Registration Status Check

The AT component will automatically create a thread for GPRS network registration status check, uses the “AT+CGREG?” command to check the GPRS network registration status, and modifies the flag bit of the network card device according to the result returned by the command, in which <stat> returns an equal to 1 or 5 in the result, indicating that the module has registered PS services on the UMTS/LTE network.

The name of the GPRS network registration status check thread is the name of the analog network card, in this case, it’s “ec200x”, and the thread’s entry function is ec200x_check_link_status_entry packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c), it will send an AT command to check the network registration of GPRS every 60s and will modify the netdev->flags in the function netdev_low_level_set_link_status based on the returned result. The parsing of the execution results for each case is as follows:

Note: The GPRS network registration status check thread will check the power_status of the module, power_status initializes to RT_FALSE by default in the ec200x_init() function, and then calls ec200x_power_on() in the ec200x_init_thread_entry() thread entry function of a thread named ec200x_net to modify the value of power_status. The value of power_status in the ec200x_power_on() function is modified to RT_TRUE depends on the definition of the power_pin pin, so the number of the power_pin must be defined in Env, which defaults to -1, you can find the definition rule in the drivers/drv_gpio.c file. It should also be noted that in the code, power_pin goes low indicates that the module is powered on, and power_pin goes high indicate that the module is in a power-down state.

The number definition of the power_pin is also crucial in the implementation of disabling the NIC (netdev_set_down) and enabling the NIC (netdev_set_up), the disabling and enabling of the NIC and the final actual call functions are ec200x_power_off() and ec200x_power_on(), so the number of the power_pin must be defined, and the example code for the NIC disable and enable is as follows

1/* "ec200x" created at the device registration, can be defined at the packages/at_device-v2.0.4/samples/at_sample_ec200x.c file */
2struct at_device * dev = at_device_get_by_name(AT_DEVICE_NAMETYPE_NETDEV, "ec200x");/* Search the AT device in names*/
3
4netdev_set_up(dev->netdev); /* Enable the corresponding network card device */
5netdev_set_down(dev->netdev); /* Disable the corresponding network card device */

1.4 Check ec200x Log Output with External Internet

The check_netdev_internet_up_work() function in rt-thread/components/net/sal_socket/src/sal_socket.c will automatically connect to the 8101 port of ''link.rt-thread.org'' for data transmission and receiving tests to determine if it is possible to connect to the External Internet. The default print level in the file is DBG_INFO, modify the test results at the end of the check_netdev_internet_up_work() function to print from 'LOG_D' to 'LOG_I' can easily find out the answer.

The execution process of this function is to submit the External Internet Check Task to the sys_work work queue in the ec200x initialization thread ec200x_init_thread_entry(), and the system work queue processing thread _workqueue_thread_entry() will continuously detect whether there is a task that needs to be run, and if so, execute the corresponding task, that is, perform the External Internet Check Task.

The execution process of the External Internet Check Task submitted to the work queue is as follows

1ec200x_init_thread_entry                                                            /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
2 |-> ec200x_power_on /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
3 |-> at_obj_exec_cmd() /* Send AT commands to initialize: EC200x rt-thread/components/net/at/src/at_client.c */
4 |-> ec200x_netdev_set_info /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
5 |-> at_device_get_by_name /* packages/at_device-v2.0.4/src/at_device.c */
6 |-> netdev_low_level_set_status /* rt-thread/components/net/netdev/src/netdev.c */
7 |-> netdev->flags |= NETDEV_FLAG_LINK_UP; /* The network status change to connected */
8 |-> netdev_low_level_set_link_status /* rt-thread/components/net/netdev/src/netdev.c */
9 |-> netdev_low_level_set_dhcp_status /* rt-thread/components/net/netdev/src/netdev.c */
10 |-> netdev_low_level_set_ipaddr /* Set local IP: rt-thread/components/net/netdev/src/netdev.c */
11 |-> sal_check_netdev_internet_up /* rt-thread/components/net/sal_socket/src/sal_socket.c */
12 |-> rt_delayed_work_init(net_work, check_netdev_internet_up_work) /* Initialize the task of External Internet Check: rt-thread/components/drivers/src/workqueue.c */
13 |-> (&work->work)->work_func = check_netdev_internet_up_work
14 |-> rt_work_submit(&(net_work->work), RT_TICK_PER_SECOND); /* rt-thread/components/drivers/src/workqueue.c */
15 |-> rt_workqueue_submit_work(sys_workq, work, time) /* Submit the task to the system work queue: rt-thread/components/drivers/src/workqueue.c */
16 |-> netdev_low_level_set_dns_server /* Set DNS server: rt-thread/components/net/netdev/src/netdev.c */
17 |-> ec200x_netdev_check_link_status /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
18 |-> rt_thread_create(ec200x_check_link_status_entry) /* Thread name is"ec200x", create GPRS network status checking thread: packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
19 |-> rt_thread_startup(ec200x_check_link_status_entry) /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
20
21/* GPRS Network Registration Status Checking Thread */
22ec200x_check_link_status_entry /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
23 |-> ec200x_check_link_status /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
24 |-> at_obj_exec_cmd("AT+CGREG?") /* Send AT commands to check the network status */
25 |-> netdev_low_level_set_link_status /* rt-thread/components/net/netdev/src/netdev.c */

System work queue initialization and task execution process is as follows

1rt_work_sys_workqueue_init                                                          /* rt-thread/components/drivers/src/workqueue.c */
2 |-> rt_workqueue_create("sys_work") /* Create system work queue: rt-thread/components/drivers/src/workqueue.c */
3 |-> rt_thread_create(_workqueue_thread_entry) /* Thread name is"sys_work", create queue thread: rt-thread/components/drivers/src/workqueue.c */
4
5_workqueue_thread_entry /* System work queue manage the thread: rt-thread/components/drivers/src/workqueue.c */
6 |-> if(rt_list_isempty)
7 |-> rt_thread_suspend(rt_thread_self()); /* Suspend itself */
8 |-> rt_schedule(); /* The task list is empty, suspend itself, switch threads */
9 |-> rt_hw_interrupt_disable /* The task list is not empty, execute accordingly, and close the interrupt */
10 |-> rt_list_entry /* Locate the task node that needs to process */
11 |-> rt_list_remove /* Removes the found task node from the task list */
12 |-> rt_hw_interrupt_enable /* Enable interrupts */
13 |-> work->work_func(work, work->work_data); /* Execute the task */

The execution process of the External Internet Connection Check task is as follows

1check_netdev_internet_up_work                                                       /* External Internet Connection Check task: rt-thread/components/net/sal_socket/src/sal_socket.c */
2 |-> Establish a connection to port 8101 of the "link.rt-thread.org" for sending and receiving the test data
3 |-> Print test result
4 |-> The sending and receiving test is successful: LOG_I("Set network interface device(%s) internet status up.", netdev->name);
5 |-> netdev->flags |= NETDEV_FLAG_INTERNET_UP;
6 |-> The sending and receiving test was failed: LOG_I("Set network interface device(%s) internet status down.", netdev->name);
7 |-> netdev->flags &= ~NETDEV_FLAG_INTERNET_UP;

1.5 AT Device Registration Process

1at_device_register                                                                  /* packages/at_device-v2.0.4/samples/at_sample_ec200x.c */
2 |-> class = at_device_class_get(class_id) /* packages/at_device-v2.0.4/src/at_device.c */
3 |-> class->device_ops->init(device) /* packages/at_device-v2.0.4/src/at_device.c */
4 |-> ec200x_init /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
5 |-> ec200x->power_status = RT_FALSE; /* default power is off. packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
6 |-> ec200x->sleep_status = RT_FALSE; /* default sleep is disabled. packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
7 |-> at_client_init /* components/net/at/src/at_client.c */
8 |-> at_client_para_init /* components/net/at/src/at_client.c */
9 |-> rt_thread_create(client_parser) /* Thread name is"at_clnt0", create AT parser thread: components/net/at/src/at_client.c */
10 |-> client_parser /* The implementation of AT Parser Thread: components/net/at/src/at_client.c */
11 |-> rt_device_find /* Search the serial port device: rt-thread/src/device.c */
12 |-> rt_device_open /* Open the serail port device: rt-thread/src/device.c */
13 |-> rt_thread_startup(client->parser) /* rt-thread/src/thread.c */
14 |-> ec200x_socket_init /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
15 |-> ec200x_netdev_add("ec200x") /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
16 |-> netdev_get_by_name("ec200x") /* rt-thread/components/net/netdev/src/netdev.c */
17 |-> netdev->ops = &ec200x_netdev_ops; /* Network Device Operation Set: packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
18 |-> sal_at_netdev_set_pf_info /* rt-thread/components/net/sal_socket/impl/af_inet_at.c */
19 |-> netdev_register /* rt-thread/components/net/netdev/src/netdev.c */
20 |-> netdev->status_callback = RT_NULL; /* rt-thread/components/net/netdev/src/netdev.c */
21 |-> netdev->addr_callback = RT_NULL; /* rt-thread/components/net/netdev/src/netdev.c */
22 |-> ec200x->power_pin /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
23 |-> ec200x->power_status_pin /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
24 |-> ec200x->wakeup_pin /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
25 |-> ec200x_netdev_set_up /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
26 |-> at_device_get_by_name /* packages/at_device-v2.0.4/src/at_device.c */
27 |-> ec200x_net_init /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
28 |-> rt_thread_create(ec200x_init_thread_entry) /* Thread name is"ec200x_net", execute AT commands to initialize Network: packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
29 |-> rt_thread_startup(ec200x_init_thread_entry) /* Enable Network Initialization Thread: packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
30 |-> netdev_low_level_set_status /* rt-thread/components/net/netdev/src/netdev.c */

1.6 AT Devices Registration Process

1ec200x_device_class_register                                                       /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
2 |-> ec200x_socket_class_register /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
3 |-> class->socket_num = AT_DEVICE_EC200X_SOCKETS_NUM; /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
4 |-> class->socket_ops = &ec200x_socket_ops; /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
5 |-> class->device_ops = &ec200x_device_ops; /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
6 |-> at_device_class_register
7/* packages/at_device-v2.0.4/src/at_device.c */

1.7 Network Enable and Disable

1.7.1 Enable Execution Process

1/* Enable Network */
2netdev_set_up(netdev) /* components/net/netdev/src/netdev.c */
3 |-> netdev->ops->set_up(netdev) /* netdev->ops = &ec200x_netdev_ops; packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
4 |-> ec200x_netdev_set_up ------------------------------| /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
5 |-> ec200x_net_init | /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
6 |-> ec200x_init_thread_entry | /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
7 |
8/* module init */ |
9ec200x_init | /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
10 |-> at_client_init | /* components/net/at/src/at_client.c */
11 |-> ec200x_socket_init | /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
12 |-> ec200x_netdev_add | /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
13 |-> netdev_register | /* rt-thread/components/net/netdev/src/netdev.c */
14 |-> ec200x_netdev_set_up ----------------------------------| /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
15 |-> ec200x_net_init /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
16 |-> ec200x_init_thread_entry /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */

1.7.2 Disable Execution Process

1/* Disable Network */
2netdev_set_down(netdev) /* components/net/netdev/src/netdev.c */
3 |-> netdev->ops->set_down(netdev); /* components/net/netdev/src/netdev.c */
4 |-> ec200x_netdev_set_down ----------------------------| /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
5 |-> ec200x_power_off | /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
6 |-> netdev_low_level_set_status(netdev, RT_FALSE) | /* rt-thread/components/net/netdev/src/netdev.c */
7 |-> netdev->flags &= ~NETDEV_FLAG_UP | /* rt-thread/components/net/netdev/src/netdev.c */
8 |-> netdev_auto_change_default | /* rt-thread/components/net/netdev/src/netdev.c */
9 |
10/* module deinit */ |
11ec200x_deinit | /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
12 |-> ec200x_netdev_set_down --------------------------------| /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */
13 |-> ec200x_power_off /* packages/at_device-v2.0.4/class/ec200x/at_device_ec200x.c */

1.8 Socket Source Code Parser

1.8.1 socket Execution Process

1#define socket(domain, type, protocol)  sal_socket(domain, type, protocol)         /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
2 |-> sal_socket /* rt-thread/components/net/sal_socket/src/sal_socket.c */
3 |-> socket_new /* rt-thread/components/net/sal_socket/src/sal_socket.c */
4 |-> socket_alloc /* rt-thread/components/net/sal_socket/src/sal_socket.c */
5 |-> sock = st->sockets[idx]; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
6 |-> sock->socket = idx + SAL_SOCKET_OFFSET; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
7 |-> sock->magic = SAL_SOCKET_MAGIC; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
8 |-> sock->netdev = RT_NULL; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
9 |-> sock->user_data = RT_NULL; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
10 |-> sal_get_socket /* rt-thread/components/net/sal_socket/src/sal_socket.c */
11 |-> socket_init /* rt-thread/components/net/sal_socket/src/sal_socket.c */
12 |-> sock->netdev = netdev; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
13 |-> SAL_NETDEV_SOCKETOPS_VALID /* rt-thread/components/net/sal_socket/src/sal_socket.c */
14 |-> pf->skt_ops->socket /* rt-thread/components/net/sal_socket/src/sal_socket.c */
15 |-> at_socket /* rt-thread/components/net/at/at_socket/at_socket.c */
16 |-> alloc_socket /* rt-thread/components/net/at/at_socket/at_socket.c */
17 |-> sock->type = socket_type; /* rt-thread/components/net/at/at_socket/at_socket.c */
18 |-> sock->state = AT_SOCKET_OPEN; /* rt-thread/components/net/at/at_socket/at_socket.c */
19 |-> sock->ops->at_set_event_cb(AT_SOCKET_EVT_RECV, at_recv_notice_cb); /* Set receiving call function: rt-thread/components/net/at/at_socket/at_socket.c */
20 |-> ec200x_socket_set_event_cb /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
21 |-> at_evt_cb_set[event] = cb; /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
22 |-> sock->ops->at_set_event_cb(AT_SOCKET_EVT_CLOSED, at_closed_notice_cb); /* Set close socket call function: rt-thread/components/net/at/at_socket/at_socket.c */
23 |-> ec200x_socket_set_event_cb /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
24 |-> at_evt_cb_set[event] = cb; /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */

1.8.2 Connect Function Execution Process

1#define connect(s, name, namelen)   sal_connect(s, name, namelen)                  /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
2 |-> sal_connect /* rt-thread/components/net/sal_socket/src/sal_socket.c */
3 |-> SAL_SOCKET_OBJ_GET /* rt-thread/components/net/sal_socket/src/sal_socket.c */
4 |-> SAL_NETDEV_IS_UP /* rt-thread/components/net/sal_socket/src/sal_socket.c */
5 |-> SAL_NETDEV_SOCKETOPS_VALID /* rt-thread/components/net/sal_socket/src/sal_socket.c */
6 |-> pf->skt_ops->connect /* rt-thread/components/net/sal_socket/src/sal_socket.c */
7 |-> at_connect /* rt-thread/components/net/at/at_socket/at_socket.c */
8 |-> at_get_socket /* rt-thread/components/net/at/at_socket/at_socket.c */
9 |-> sock->ops->at_connect /* rt-thread/components/net/at/at_socket/at_socket.c */
10 |-> ec200x_socket_connect /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */

1.8.3 Send Function Execution Process

1#define send(s, dataptr, size, flags)               sal_sendto(s, dataptr, size, flags, NULL, NULL) /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
2#define sendto(s, dataptr, size, flags, to, tolen) sal_sendto(s, dataptr, size, flags, to, tolen) /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
3 |-> sal_sendto /* rt-thread/components/net/sal_socket/src/sal_socket.c */
4 |-> SAL_SOCKET_OBJ_GET /* rt-thread/components/net/sal_socket/src/sal_socket.c */
5 |-> SAL_NETDEV_IS_UP /* rt-thread/components/net/sal_socket/src/sal_socket.c */
6 |-> SAL_NETDEV_SOCKETOPS_VALID /* rt-thread/components/net/sal_socket/src/sal_socket.c */
7 |-> pf->skt_ops->sendto /* rt-thread/components/net/sal_socket/src/sal_socket.c */
8 |-> at_sendto /* rt-thread/components/net/at/at_socket/at_socket.c */
9 |-> at_get_socket /* rt-thread/components/net/at/at_socket/at_socket.c */
10 |-> sock->ops->at_send /* rt-thread/components/net/at/at_socket/at_socket.c */
11 |-> ec200x_socket_send /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */

1.8.4 recv Function Execution Process

When the recv() function executes, the URC function received by the EC200x places the data into the recvpkt_list, and then the recv() function takes the data from the recvpkt_list.

1#define recv(s, mem, len, flags)                    sal_recvfrom(s, mem, len, flags, NULL, NULL)    /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
2#define recvfrom(s, mem, len, flags, from, fromlen) sal_recvfrom(s, mem, len, flags, from, fromlen) /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
3 |-> sal_recvfrom /* rt-thread/components/net/sal_socket/src/sal_socket.c */
4 |-> SAL_SOCKET_OBJ_GET /* rt-thread/components/net/sal_socket/src/sal_socket.c */
5 |-> SAL_NETDEV_IS_UP /* rt-thread/components/net/sal_socket/src/sal_socket.c */
6 |-> SAL_NETDEV_SOCKETOPS_VALID /* rt-thread/components/net/sal_socket/src/sal_socket.c */
7 |-> pf->skt_ops->recvfrom /* rt-thread/components/net/sal_socket/src/sal_socket.c */
8 |-> at_recvfrom /* rt-thread/components/net/at/at_socket/at_socket.c */
9 |-> at_get_socket /* rt-thread/components/net/at/at_socket/at_socket.c */
10 |-> at_recvpkt_get(&(sock->recvpkt_list)...) /* Get data from linked list rt-thread/components/net/at/at_socket/at_socket.c */
11
12/* The URC function received by EC200x*/
13urc_recv_func /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
14 |-> recv_buf = (char *) rt_calloc(1, bfsz); /* Request space for at_recv_pkt, mounted in the rlist list */
15 |-> at_client_obj_recv /* rt-thread/components/net/at/src/at_client.c */
16 |-> at_client_getchar /* rt-thread/components/net/at/src/at_client.c */
17 |-> at_evt_cb_set[AT_SOCKET_EVT_RECV](socket, AT_SOCKET_EVT_RECV, recv_buf, bfsz); /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
18 |-> at_recv_notice_cb /* rt-thread/components/net/at/at_socket/at_socket.c */
19 |-> at_recvpkt_put(&(sock->recvpkt_list), buff, bfsz); /* rt-thread/components/net/at/at_socket/at_socket.c */
20 |-> pkt->buff = (char *) ptr; /* Point the buff to the space that requested earlier: rt-thread/components/net/at/at_socket/at_socket.c */
21 |-> rt_slist_append /* Mount to linked list */

1.8.5 closesocket Function Execution Process

1#define closesocket(s)  sal_closesocket(s)                                          /* rt-thread/components/net/sal_socket/include/socket/sys_socket/sys/socket.h */
2 |-> sal_closesocket /* rt-thread/components/net/sal_socket/src/sal_socket.c */
3 |-> SAL_SOCKET_OBJ_GET /* rt-thread/components/net/sal_socket/src/sal_socket.c */
4 |-> SAL_NETDEV_SOCKETOPS_VALID /* rt-thread/components/net/sal_socket/src/sal_socket.c */
5 |-> pf->skt_ops->closesocket /* rt-thread/components/net/sal_socket/src/sal_socket.c */
6 |-> at_closesocket /* rt-thread/components/net/at/at_socket/at_socket.c */
7 |-> sock->ops->at_closesocket /* rt-thread/components/net/at/at_socket/at_socket.c */
8 |-> ec200x_socket_close /* packages/at_device-v2.0.4/class/ec200x/at_socket_ec200x.c */
9 |-> free_socket /* rt-thread/components/net/at/at_socket/at_socket.c */
10 |-> socket_delete /* rt-thread/components/net/sal_socket/src/sal_socket.c */
11 |-> sock = sal_get_socket(socket); /* rt-thread/components/net/sal_socket/src/sal_socket.c */
12 |-> sock->magic = 0; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
13 |-> sock->netdev = RT_NULL; /* rt-thread/components/net/sal_socket/src/sal_socket.c */
14 |-> socket_free /* rt-thread/components/net/sal_socket/src/sal_socket.c */
15 |-> rt_free(sock); /* rt-thread/src/memheap.c */
16 |-> rt_memheap_free /* rt-thread/src/memheap.c */

--

--

RT-Thread IoT OS
RT-Thread IoT OS

Written by RT-Thread IoT OS

An Open-Source Community-Powered Real-Time Operating System (RTOS) Project! Let’s develop, DIY, create, share, and explore this new IoT World together!

No responses yet