static int handle_put_light(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt,coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
{
if (inpkt->payload.len == 0)
return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, COAP_RSPCODE_BAD_REQUEST, COAP_CONTENTTYPE_TEXT_PLAIN);
if (inpkt->payload.p[0] == '1')
{
light = '1';
UARTWrite(1,"ON\n");
return coap_make_response(scratch, outpkt, (const UINT8_VAL *)&light, 1, id_hi, id_lo, COAP_RSPCODE_CHANGED, COAP_CONTENTTYPE_TEXT_PLAIN);
}
else
{
light = '0';
UARTWrite(1,"OFF\n");
return coap_make_response(scratch, outpkt, (const UINT8_VAL *)&light, 1, id_hi, id_lo, COAP_RSPCODE_CHANGED, COAP_CONTENTTYPE_TEXT_PLAIN);
}
}
这是我的代码,我在第 5 行遇到错误。该结构定义为
typedef struct
{
coap_header_t hdr;
coap_buffer_t tok;
uint8_t numopts;
coap_option_t opts[MAXOPT];
coap_buffer_t payload;
} coap_packet_t;
typedef struct
{
const UINT8_VAL *p;
size_t len;
} coap_buffer_t;
当我尝试使用主要是 C 编译器的 Microchip c30 编译器进行编译时,出现以下错误。
Error :- error: invalid operands to binary ==
请帮帮我!!
最佳答案
尝试使用 UINT8_VAL 的 Val
成员进行比较:
inpkt->payloadp[0].Val == '1'
关于c - 为 MicroChip 编译时出错 'invalid operands to binary ==',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23934470/