- packages\umqtt\src\umqtt.c(247):
- 167: argument of type “struct umqtt_client *” is incompatible with parameter of type “int”
- packages\umqtt\src\umqtt.c(679):
- 167: argument of type “struct umqtt_client *” is incompatible with parameter of type “int”
- packages\umqtt\src\pkgs\umqtt_pkgs_decode.c(205):
- 513: a value of type “char” cannot be assigned to an entity of type “rt_uint8_t *”
- packages\umqtt\tests\umqtt_test_table.h(3):
- 144: a value of type “char [30300]” cannot be used to initialize an entity of type “const char [3000]”
- 互斥量在中断中操作
- packages\umqtt\src\umqtt.c(多行):
- 需增显示转换
- 未完待续。。。
packages\umqtt\src\umqtt.c(247):
error:
167: argument of type “struct umqtt_client *” is incompatible with parameter of type “int”
suggestion:
umqtt_trans_disconnect(client);
改为umqtt_trans_disconnect((int)client);
packages\umqtt\src\umqtt.c(679):
error:
167: argument of type “struct umqtt_client *” is incompatible with parameter of type “int”
suggestion:
umqtt_trans_disconnect(client);
改为umqtt_trans_disconnect((int)client);
packages\umqtt\src\pkgs\umqtt_pkgs_decode.c(205):
error:
513: a value of type “char” cannot be assigned to an entity of type “rt_uint8_t *”
suggestion:
报错代码为suback_msg->ret_qos[(suback_msg->topic_count)++] = umqtt_readChar(&curdata);
umqtt_readChar返回值为char
struct umqtt_pkgs_suback /* subscribe ack */
{
/* variable header */
rt_uint16_t packet_id; /* packet id */
/* payload */
rt_uint8_t *ret_qos[PKG_UMQTT_SUBRECV_DEF_LENGTH]; /* return code - enum Qos - 0/1/2 */
/* not payload datas */
rt_uint8_t topic_count; /* topic name count */
};
根据作者意图,可能需要将umqtt_pkgs_suback中rt_uint8_t *ret_qos[PKG_UMQTT_SUBRECV_DEF_LENGTH];
改为rt_uint8_t ret_qos[PKG_UMQTT_SUBRECV_DEF_LENGTH];
packages\umqtt\tests\umqtt_test_table.h(3):
error:
144: a value of type “char [30300]” cannot be used to initialize an entity of type “const char [3000]”
suggestion
UMQTT_BIG_MSG_NUM为3000,定义了3000个字节的数组,但是里面存放了30300个字节,导致报错。
#define UMQTT_BIG_MSG_NUM 3000
static const char user_big_msg[UMQTT_BIG_MSG_NUM] = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \
...
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 \
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
互斥量在中断中操作
error:
msh />Function[rt_mutex_take] shall not be used in ISR
(0) assertion failed at function:rt_mutex_take, line number:660
追踪
使用软件定时器来管理keepalive和reconnect,定时时间到执行umqtt_uplink_timer_callback,而回调中keepalive和reconnect发送时加锁调用了rt_mutex_take。即在systick中断中执行了rt_mutex_take。
栈状态如下:
或许可以改变定时的方式比如开辟一个线程?或者改变加锁方式?或者借鉴ali及ucloud采用yield的方式?
packages\umqtt\src\umqtt.c(多行):
error:
packages\umqtt\src\umqtt.c(1065): error: #29: expected an expression
追踪
报错位置调用了rt_list_for_each_entry
/**
* rt_list_for_each_entry - iterate over list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the list_struct within the struct.
*/
#define rt_list_for_each_entry(pos, head, member) \
for (pos = rt_list_entry((head)->next, typeof(*pos), member); \
&pos->member != (head); \
pos = rt_list_entry(pos->member.next, typeof(*pos), member))
typeof() 是GUN C提供的一种特性,mdk和IAR(待确认) 并不支持typeof,至少v5是这样的。我通过在编译命令(Options for Target —> C/C++ —> Misc Controls)中添加加 —GNU 解决了这个问题。
但是需要在更大范围内解决这个问题。
需增显示转换
error:
如上几处在GNU C中是不会报错的,但是在MDK中需要显示转换(强制转换)
此外还有诸多警告信息,作者自行查看