Toggle navigation
首页
问答
文章
积分商城
专家
专区
更多专区...
文档中心
返回主站
搜索
提问
会员
中心
登录
注册
at_socket
at_socket在连接udp服务器时出现“加载指令访问错误异常”
发布于 2024-12-13 11:16:46 浏览:82
订阅该版
```c static int ml307_socket_connect(struct at_socket *socket, char *ip, int32_t port, enum at_socket_type type, rt_bool_t is_client) { uint32_t event = 0; rt_bool_t retryed = RT_FALSE; at_response_t resp = RT_NULL; int result = RT_EOK, event_result = 0; int device_socket = (int) socket->user_data; struct at_device *device = (struct at_device *) socket->device; RT_ASSERT(ip); RT_ASSERT(port >= 0); resp = at_create_resp(128, 0, 5 * RT_TICK_PER_SECOND); if (resp == RT_NULL) { LOG_E("no memory for ml307 device(%s) response structure.", device->name); return -RT_ENOMEM; } __retry: /* clear socket connect event */ event = SET_EVENT(device_socket, ML307_EVENT_CONN_OK | ML307_EVENT_CONN_FAIL); ml307_socket_event_recv(device, event, 0, RT_EVENT_FLAG_OR); if (is_client) { switch (type) { case AT_SOCKET_TCP: /* send AT commands(eg: AT+MIPOPEN=0,"TCP","x.x.x.x", 1234) to connect TCP server */ if (at_obj_exec_cmd(device->client, RT_NULL, "AT+MIPOPEN=%d,\"TCP\",\"%s\",%d", device_socket, ip, port) < 0) { result = -RT_ERROR; goto __exit; } break; case AT_SOCKET_UDP: if (at_obj_exec_cmd(device->client, RT_NULL, "AT+MIPOPEN=%d,\"UDP\",\"%s\",%d", device_socket, ip, port) < 0) { result = -RT_ERROR; goto __exit; } break; default: LOG_E("ml307 device(%s) not supported connect type : %d.", device->name, type); result = -RT_ERROR; goto __exit; } } rt_kprintf("AT+MIPOPEN = 1\n"); /* waiting result event from AT URC, the device default connection timeout is 75 seconds, but it set to 10 seconds is convenient to use */ if (ml307_socket_event_recv(device, SET_EVENT(device_socket, 0), 10 * RT_TICK_PER_SECOND, RT_EVENT_FLAG_OR) < 0) { LOG_E("ml307 device(%s) socket(%d) connect failed, wait connect result timeout.",device->name, device_socket); result = -RT_ETIMEOUT; goto __exit; } rt_kprintf("AT+MIPOPEN = 2\n"); /* waiting OK or failed result */ event_result = ml307_socket_event_recv(device, ML307_EVENT_CONN_OK | ML307_EVENT_CONN_FAIL, 1 * RT_TICK_PER_SECOND, RT_EVENT_FLAG_OR); if (event_result < 0) { LOG_E("ml307 device(%s) socket(%d) connect failed, wait connect OK|FAIL timeout.", device->name, device_socket); result = -RT_ETIMEOUT; goto __exit; } rt_kprintf("AT+MIPOPEN = 3\n"); /* check result */ if (event_result & ML307_EVENT_CONN_FAIL) { if (retryed == RT_FALSE) { LOG_D("ml307 device(%s) socket(%d) connect failed, maybe the socket was not be closed at the last time and now will retry.", device->name, device_socket); if (ml307_socket_close(socket) < 0) { result = -RT_ERROR; goto __exit; } retryed = RT_TRUE; goto __retry; } LOG_E("ml307 device(%s) socket(%d) connect failed.", device->name, device_socket); result = -RT_ERROR; goto __exit; } __exit: if (resp) { at_delete_resp(resp); } return result; } ``` 执行了 ```c if (at_obj_exec_cmd(device->client, RT_NULL, "AT+MIPOPEN=%d,\"UDP\",\"%s\",%d", device_socket, ip, port) < 0) ``` 之后异常。 下面是AT指令数据 ``` [D/AT] sendline: 0000-0020: 41 54 2B 4D 49 50 4F 50 45 4E 3D 30 2C 22 55 44 50 22 2C 22 31 31 38 2E 33 31 2E 31 35 2E 31 35 AT+MIPOPEN=0,"UDP","118.31.15.15 [D/AT] sendline: 0020-0040: 32 22 2C 38 31 30 31 0D 0A 2",8101.. [D/AT] recvline: 0000-0020: 0D 0A .. [D/AT] recvline: 0000-0020: 4F 4B 0D 0A OK.. [D/AT] recvline: 0000-0020: 0D 0A .. [D/AT] recvline: 0000-0020: 2B 4D 49 50 4F 50 45 4E 3A 20 30 2C 30 0D 0A +MIPOPEN: 0,0.. CPU Exception: NO.5 x1: 40121ff0 x2: 300552a0 x3: 4025068c x4: deadbeef x5: 00001000 x6: 00000000 x7: 00000000 x8: 00010001 x9: 30054970 x10: 01010101 x11: 01010101 x12: 00000000 x13: 300541e0 x14: 00000001 x15: 000000ff x16: 00000001 x17: 30053e72 x18: 80006088 x19: 3005498c x20: 00000000 x21: 0000000d x22: 4020d51c x23: 40209c5c x24: 4020d514 x25: 40209c60 x26: 4020d4d0 x27: 30054c0c x28: 00000001 x29: 00000019 x30: 0000000a x31: 7fffffff mcause : 30000005 mtval : 0101012d mepc : 4012201c mstatus: 80007800 ```
查看更多
0
个回答
默认排序
按发布时间排序
暂无答案,快来添加答案吧
撰写答案
登录
注册新账号
关注者
0
被浏览
82
关于作者
ZJNL_8742
这家伙很懒,什么也没写!
提问
3
回答
1
被采纳
0
关注TA
发私信
相关问题
1
这个at_device初始联网等操作为什么要在main函数之前呢?
2
关与AT client几个操作函数的问题
3
服务器重启后,socket如何进行重连?
4
ntp服务器无法同步问题
5
ntp与mqtt同时使用时出现socket(1)连接超时。
6
AT Socket 支持的 API 不完整,没有实现 accept
7
使用at_socket 怎么完成的创建socket
8
AT socket 接收较长数据 的问题
9
AT Socket 功能启动时报错
10
sal_socket.c 报错
推荐文章
1
RT-Thread应用项目汇总
2
玩转RT-Thread系列教程
3
国产MCU移植系列教程汇总,欢迎查看!
4
机器人操作系统 (ROS2) 和 RT-Thread 通信
5
五分钟玩转RT-Thread新社区
6
【技术三千问】之《玩转ART-Pi》,看这篇就够了!干货汇总
7
关于STM32H7开发板上使用SDIO接口驱动SD卡挂载文件系统的问题总结
8
STM32的“GPU”——DMA2D实例详解
9
RT-Thread隐藏的宝藏之completion
10
【ART-PI】RT-Thread 开启RTC 与 Alarm组件
最新文章
1
RT-Thread项目助手v0.2.0 - 支持Env Windows
2
RttreadV5.10上,GD32F450Z RTC时间显示问题
3
rt-smart启动流程分析
4
EtherKit快速上手PROFINET
5
RTThread USB转串口无法接收数据
热门标签
RT-Thread Studio
串口
Env
LWIP
SPI
AT
Bootloader
Hardfault
CAN总线
FinSH
ART-Pi
USB
DMA
文件系统
RT-Thread
SCons
RT-Thread Nano
线程
MQTT
STM32
RTC
FAL
rt-smart
ESP8266
I2C_IIC
UART
WIZnet_W5500
ota在线升级
PWM
cubemx
flash
freemodbus
BSP
packages_软件包
潘多拉开发板_Pandora
定时器
ADC
flashDB
GD32
socket
编译报错
中断
Debug
rt_mq_消息队列_msg_queue
SFUD
msh
keil_MDK
ulog
MicroPython
C++_cpp
本月问答贡献
出出啊
1517
个答案
342
次被采纳
小小李sunny
1444
个答案
290
次被采纳
张世争
813
个答案
177
次被采纳
crystal266
547
个答案
161
次被采纳
whj467467222
1222
个答案
149
次被采纳
本月文章贡献
出出啊
1
篇文章
2
次点赞
小小李sunny
1
篇文章
1
次点赞
张世争
1
篇文章
3
次点赞
crystal266
2
篇文章
2
次点赞
whj467467222
2
篇文章
2
次点赞
回到
顶部
发布
问题
分享
好友
手机
浏览
扫码手机浏览
投诉
建议
回到
底部