This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2650:读取 CC2650 LaunchPad 的输入引脚

Guru**** 2553620 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/other-wireless-group/other-wireless/f/other-wireless-technologies-forum/815814/cc2650-read-the-input-pin-of-cc2650-launch-pad

器件型号:CC2650

你好!!! 我是一名学生。 我希望通过 CC22650输入引脚输入数据。 我正在使用 contiki-udp-client.c 文件进行开发。 任何人都知道读取输入引脚的函数/代码?? 如果有人知道这一点,请回复!!!!!!

代码如下所示;

#include "contiki.h"
#include "contiki-lib.h"
#include "contiki-net.h"
#include "net/IP/resolv.h"

#include
#include

#define debug debug_print
#include "net/IP/UIP-debug.h"

#define SEND_INTERVAL 15 * CLOCK _second
#define MAX_PAYLOAD_LEN 40.

静态结构 uip_udp_conn * client_conn;
/*------------------ *
进程(udp_client_process、"UDP 客户端进程");
autostart_processes (&resolv_process、&udp_client_process);
/*------------------ *
静态空
TCPIP_handler (空)

char *str;

if (uip_newdata()){
STR = UIP_appdata;
STR[UIP_datalen ()]='\0';
printf ("服务器的响应:'%s'、str);


/*------------------ *
静态 char buf[MAX_PAYLOAD_LEN];
静态空
TIMEOUT_Handler (空)

静态 int seq_id;

printf ("发送到的客户端:");
PRINT6ADDR (&client_conn->ripaddr);
sprintf (buf、"您从客户端发出%d 个问候"、++Seq_id);
printf ("(msg:%s)\n"、buf);
#if send_to_large_packet_to_test_碎片
uip_udp_packet_send (client_conn、buf、uip_appdATA_size);
#else /* send_to_large_packet_to_test_碎片*/
uip_udp_packet_send (client_conn、buf、strlen (buf));
#endif /* send_to_large_packet_to_test_碎片*/

/*------------------ *
静态空
print_local_addresses (void)

int i;
uint8_t state;

printf ("客户端 IPv6地址:");
对于(I = 0;I < UIP_DS6_ADDR_NB;i++){
状态= UIP_ds6_if.addr_list[i].state;
if (uip_ds6_if.addr_list[i].isused &&
(STATE = ADDR_Tentative || STATE = ADDR_Preferred)){
PRINT6ADDR (&UIP_ds6_if.addr_list[i].ipaddr);
printf ("\n");



/*------------------ *
#if UIP_CONF_ROUTER
静态空
SET_GLOBAL_ADDRESS (空)

uip_ipaddr_t ipaddr;

UIP_ip6addr (&ipaddr、0xaaaa、0、0、0、 0、0、0、0);
uip_ds6_set_addr_iid (&ipaddr、&uip_lladdr);
uip_ds6_addr_add (&ipaddr、0、ADDR_autoconf);

#endif /* UIP_CONF_ROUTER */
/*------------------ *
静态 resolv_status_t
SET_CONNECT_ADDRESS (UIP_ipaddr_t *地址)

#ifndef UDP_CONNECT_ADDR
#if RESOLV_CONF_supports_MDNS
#define udp_connection_ADDR contiki-udp-server.local
#Elif UIP_CONF_ROUTER
#define UDP_CONNECT_ADDR AAAA:0:0:0:0212:7404:0004:0404
其他
#define UDP_CONNECT_ADDR fe80:0:0:0:6466:6666:6666:6666
#endif
#endif /*!udp_connection_ADDR *

#define _QUOTEME (x)#x
#define QUOTEME (x)_QUOTEME (x)

resolv_status_t status = RESOLV_STATUS_ERROR;

if (uiplib_ipaddrconv (QUOTEME (udp_connection_ADDR)、ipaddr)= 0){
uip_ipaddr_t *已解析_addr = NULL;
status = resolv_lookup (QUOTEME (UDP_CONNECT_ADDR)、Resolved_addr);
if (status =RESOLV_STATUS_UNCRACK_|| status =RESOLV_STATUS_EXPIREEDed){
printf ("正在尝试查找%s\n"、QUOTEME (udp_connection_ADDR));
resolv_query (QUOTEME (UDP_CONNECT_ADDR));
状态= RESOLV_STATUS_RESolving;
}否则、如果(status = RESOLV_STATUS_Cached && Resolved_addr!= NULL){
printf ("查找\"%s\"已成功!\n",QUOTEME (udp_connection_ADDR));
}否则、如果(status = RESOLV_STATUS_RESALCRACing){
printf ("仍在查找\"%s\"...\n",QUOTEME (UDP_CONNECT_ADDR));
}否则{
printf ("查找\"%s\"失败。 状态=%d\n",QUOTEME (UDP_CONNECT_ADDR),状态);

if (resolved_addr)
uip_ipaddr_copy (ipaddr、resolved_addr);
}否则{
状态= RESOLV_STATUS_Cached;

退货状态;

/*------------------ *
process_thread (udp_client_process、EV、data)

静态结构 etimer et;
uip_ipaddr_t ipaddr;

process_bege();
printf ("UDP 客户端进程已启动\n");

#if UIP_CONF_ROUTER
set_global_address();
#endif

print_local_addresses();

静态 resolv_status_t status = RESOLV_STATUS_UNCached;
while (status!= RESOLV_STATUS_Cached){
状态= SET_CONNECT_ADDRESS (&ipaddr);

if (status == RESOLV_STATUS_RESolving){
Process_Wait_event_until (EV = resolv_event_found);
}否则、如果(status!= RESOLV_STATUS_Cached){
printf ("无法获取连接地址。\n");
process_yield ();

/*与远程主机的新连接*/
client_conn = udp_new (&ipaddr、UIP_HTONS (3000)、NULL);
UDP_BIND (client_conn、UIP_HTONS (3001));

printf("创建了与服务器的连接");
PRINT6ADDR (&client_conn->ripaddr);
printf ("本地/远程端口%u/%u\n"、
UIP_HTONS (client_conn->lport)、UIP_HTONS (client_conn->rport);

etimer_set (&et、send_interval);
while (1){
process_yield ();
if (etimer_expired (&et)){
timeout_handler();
etimer_restart (&et);
}否则、如果(EV = TCPIP_EVENT){
TCPIP_handler();

process_end();

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    由于您是初学者、我建议您阅读

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 YK Chen!!! 非常感谢。 感谢您的持续支持。