您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ sys_mbox_new函数代码示例

51自学网 2021-06-03 08:37:17
  C++
这篇教程C++ sys_mbox_new函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中sys_mbox_new函数的典型用法代码示例。如果您正苦于以下问题:C++ sys_mbox_new函数的具体用法?C++ sys_mbox_new怎么用?C++ sys_mbox_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了sys_mbox_new函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: accept_function

static err_taccept_function(void *arg, struct tcp_pcb *newpcb, err_t err){  sys_mbox_t mbox;  struct netconn *newconn;  struct netconn *conn;  #if API_MSG_DEBUG#if TCP_DEBUG  tcp_debug_print_state(newpcb->state);#endif /* TCP_DEBUG */#endif /* API_MSG_DEBUG */  conn = (struct netconn *)arg;  mbox = conn->acceptmbox;  newconn = memp_malloc(MEMP_NETCONN);  if (newconn == NULL) {    return ERR_MEM;  }  newconn->recvmbox = sys_mbox_new();  if (newconn->recvmbox == SYS_MBOX_NULL) {    memp_free(MEMP_NETCONN, newconn);    return ERR_MEM;  }  newconn->mbox = sys_mbox_new();  if (newconn->mbox == SYS_MBOX_NULL) {    sys_mbox_free(newconn->recvmbox);    memp_free(MEMP_NETCONN, newconn);    return ERR_MEM;  }  newconn->sem = sys_sem_new(0);  if (newconn->sem == SYS_SEM_NULL) {    sys_mbox_free(newconn->recvmbox);    sys_mbox_free(newconn->mbox);    memp_free(MEMP_NETCONN, newconn);    return ERR_MEM;  }  /* Allocations were OK, setup the PCB etc */  newconn->type = NETCONN_TCP;  newconn->pcb.tcp = newpcb;  setup_tcp(newconn);  newconn->acceptmbox = SYS_MBOX_NULL;  newconn->err = err;  /* Register event with callback */  if (conn->callback)  {    (*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);  }  /* We have to set the callback here even though   * the new socket is unknown. Mark the socket as -1. */  newconn->callback = conn->callback;  newconn->socket = -1;  newconn->recv_avail = 0;    sys_mbox_post(mbox, newconn);  return ERR_OK;}
开发者ID:AldenHiggins,项目名称:ELEC424-Lab06-Scheduling-with-FreeRTOS,代码行数:56,


示例2: void

structnetconn *netconn_new_with_proto_and_callback(struct stack *stack, enum netconn_type t, u16_t proto,                                   void (*callback)(struct netconn *, enum netconn_evt, u16_t len)){  struct netconn *conn;  struct api_msg msg;  conn = memp_malloc(MEMP_NETCONN);  if (conn == NULL) {    return NULL;  }    conn->stack = stack;    conn->err = ERR_OK;  conn->type = t;  conn->pcb.tcp = NULL;  if ((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) {    memp_free(MEMP_NETCONN, conn);    return NULL;  }  /*conn->recvmbox = SYS_MBOX_NULL;*/  if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {    memp_free(MEMP_NETCONN, conn);    return NULL;  }  conn->connected = 0;  conn->acceptmbox = SYS_MBOX_NULL;  conn->sem = SYS_SEM_NULL;  conn->state = NETCONN_NONE;  conn->socket = 0;  conn->callback = callback;  conn->recv_avail = 0;  msg.type = API_MSG_NEWCONN;  msg.msg.msg.bc.port = proto; /* misusing the port field */  msg.msg.conn = conn;    api_msg_post(conn->stack, &msg);      sys_mbox_fetch(conn->mbox, NULL);  if ( conn->err != ERR_OK ) {    memp_free(MEMP_NETCONN, conn);    return NULL;  }  return conn;}
开发者ID:virtualsquare,项目名称:view-os,代码行数:49,


示例3: fwtcp_create

struct fwtcp *fwtcp_create(struct fwspec *fwspec){    struct fwtcp *fwtcp;    SOCKET lsock;    int status;    err_t error;    lsock = proxy_bound_socket(fwspec->sdom, fwspec->stype, &fwspec->src.sa);    if (lsock == INVALID_SOCKET) {        perror("socket");        return NULL;    }    fwtcp = (struct fwtcp *)malloc(sizeof(*fwtcp));    if (fwtcp == NULL) {        closesocket(lsock);        return NULL;    }    fwtcp->pmhdl.callback = fwtcp_pmgr_listen;    fwtcp->pmhdl.data = (void *)fwtcp;    fwtcp->pmhdl.slot = -1;    fwtcp->sock = lsock;    fwtcp->fwspec = *fwspec;    /* struct copy */    error = sys_mbox_new(&fwtcp->connmbox, 16);    if (error != ERR_OK) {        closesocket(lsock);        free(fwtcp);        return (NULL);    }#define CALLBACK_MSG(MSG, FUNC)                         /    do {                                                /        fwtcp->MSG.type = TCPIP_MSG_CALLBACK_STATIC;    /        fwtcp->MSG.sem = NULL;                          /        fwtcp->MSG.msg.cb.function = FUNC;              /        fwtcp->MSG.msg.cb.ctx = (void *)fwtcp;          /    } while (0)    CALLBACK_MSG(msg_connect, fwtcp_pcb_connect);    CALLBACK_MSG(msg_delete,  fwtcp_pcb_delete);#undef CALLBACK_MSG    status = pollmgr_add(&fwtcp->pmhdl, fwtcp->sock, POLLIN);    if (status < 0) {        sys_mbox_free(&fwtcp->connmbox);        closesocket(lsock);        free(fwtcp);        return NULL;    }    fwtcp->next = fwtcp_list;    fwtcp_list = fwtcp;    return fwtcp;}
开发者ID:MadHacker217,项目名称:VirtualBox-OSE,代码行数:60,


示例4: netconn_listen

err_tnetconn_listen(struct netconn *conn){  struct api_msg *msg;  if (conn == NULL) {    return ERR_VAL;  }  if (conn->acceptmbox == SYS_MBOX_NULL) {    conn->acceptmbox = sys_mbox_new();    if (conn->acceptmbox == SYS_MBOX_NULL) {      return ERR_MEM;    }  }    if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) {    return (conn->err = ERR_MEM);  }  msg->type = API_MSG_LISTEN;  msg->msg.conn = conn;  api_msg_post(msg);  sys_mbox_fetch(conn->mbox, NULL);  memp_free(MEMP_API_MSG, msg);  return conn->err;}
开发者ID:KublaikhanGeek,项目名称:dd-wrt,代码行数:26,


示例5: netconn_connect

err_tnetconn_connect(struct netconn *conn, struct ip_addr *addr,       u16_t port){  struct api_msg *msg;    if (conn == NULL) {    return ERR_VAL;  }  if (conn->recvmbox == SYS_MBOX_NULL) {    if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {      return ERR_MEM;    }  }    if ((msg = memp_malloc(MEMP_API_MSG)) == NULL) {    return ERR_MEM;  }  msg->type = API_MSG_CONNECT;  msg->msg.conn = conn;    msg->msg.msg.bc.ipaddr = addr;  msg->msg.msg.bc.port = port;  api_msg_post(msg);  sys_mbox_fetch(conn->mbox, NULL);  memp_free(MEMP_API_MSG, msg);  return conn->err;}
开发者ID:KublaikhanGeek,项目名称:dd-wrt,代码行数:29,


示例6: memp_mallocp

/*-----------------------------------------------------------------------------------*/structnetconn *netconn_new(enum netconn_type t){  struct netconn *conn;  conn = memp_mallocp(MEMP_NETCONN);  if (conn == NULL) {    return NULL;  }  conn->type = t;  conn->pcb.tcp = NULL;  if ((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) {    memp_freep(MEMP_NETCONN, conn);    return NULL;  }  conn->recvmbox = SYS_MBOX_NULL;  conn->acceptmbox = SYS_MBOX_NULL;  conn->sem = SYS_SEM_NULL;  conn->state = NETCONN_NONE;  conn->socket = 0;  conn->callback = 0;  conn->recv_avail = 0;  return conn;}
开发者ID:foreverlikeyou9999,项目名称:kos-ports,代码行数:26,


示例7: ucos_test

void ucos_test(void){	char *str1 = "!";	char *str2 = "?";	   OSInit();	//mbox = OSQCreate (queue, sizeof(queue)/sizeof(queue[0]));	//dprintf("OSQCreate return:0x%8x/r/n",mbox);		/*install os timer*/		//sys_timer_start();    //OSTaskCreate(task1,(void *)str1,&task1_stk[1024],11);    //OSTaskCreate(task2,(void *)str2,&task2_stk[1024],10);    //OSTaskCreate(task3,(void *)"*",&task3_stk[1024],11);    //debug_enable = 1;	sys_thread_new("thread1", task1, str1, 1024, 8);	sys_thread_new("thread2", task2, str2, 1024, 9);	sys_thread_new("thread3", task3, str2, 1024, 10);	sys_mbox_new(&sys_mbox, 30);	//sys_sem_new(&sys_sem, 0);	sys_mutex_new(&sys_mutex);    OSStart();	    while(1)    {        dprintf("os runtime error");    }}
开发者ID:rargo,项目名称:app,代码行数:29,


示例8: lwip_netconn_do_listen

/** * Set a TCP pcb contained in a netconn into listen mode * Called from netconn_listen. * * @param msg the api_msg_msg pointing to the connection */voidlwip_netconn_do_listen(struct api_msg_msg *msg){  if (ERR_IS_FATAL(msg->conn->last_err)) {    msg->err = msg->conn->last_err;  } else {    msg->err = ERR_CONN;    if (msg->conn->pcb.tcp != NULL) {      if (NETCONNTYPE_GROUP(msg->conn->type) == NETCONN_TCP) {        if (msg->conn->state == NETCONN_NONE) {          struct tcp_pcb* lpcb;#if LWIP_IPV6          if ((msg->conn->flags & NETCONN_FLAG_IPV6_V6ONLY) == 0) {#if TCP_LISTEN_BACKLOG            lpcb = tcp_listen_dual_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog);#else  /* TCP_LISTEN_BACKLOG */            lpcb = tcp_listen_dual(msg->conn->pcb.tcp);#endif /* TCP_LISTEN_BACKLOG */          } else#endif /* LWIP_IPV6 */          {#if TCP_LISTEN_BACKLOG            lpcb = tcp_listen_with_backlog(msg->conn->pcb.tcp, msg->msg.lb.backlog);#else  /* TCP_LISTEN_BACKLOG */            lpcb = tcp_listen(msg->conn->pcb.tcp);#endif /* TCP_LISTEN_BACKLOG */          }          if (lpcb == NULL) {            /* in this case, the old pcb is still allocated */            msg->err = ERR_MEM;          } else {            /* delete the recvmbox and allocate the acceptmbox */            if (sys_mbox_valid(&msg->conn->recvmbox)) {              /** @todo: should we drain the recvmbox here? */              sys_mbox_free(&msg->conn->recvmbox);              sys_mbox_set_invalid(&msg->conn->recvmbox);            }            msg->err = ERR_OK;            if (!sys_mbox_valid(&msg->conn->acceptmbox)) {              msg->err = sys_mbox_new(&msg->conn->acceptmbox, DEFAULT_ACCEPTMBOX_SIZE);            }            if (msg->err == ERR_OK) {              msg->conn->state = NETCONN_LISTEN;              msg->conn->pcb.tcp = lpcb;              tcp_arg(msg->conn->pcb.tcp, msg->conn);              tcp_accept(msg->conn->pcb.tcp, accept_function);            } else {              /* since the old pcb is already deallocated, free lpcb now */              tcp_close(lpcb);              msg->conn->pcb.tcp = NULL;            }          }        }      } else {        msg->err = ERR_ARG;      }    }  }  TCPIP_APIMSG_ACK(msg);}
开发者ID:Akagi201,项目名称:lwip,代码行数:66,


示例9: netconn_connect

err_tnetconn_connect(struct netconn *conn, struct ip_addr *addr,       u16_t port){	struct api_msg msg;    if (conn == NULL) {    return ERR_VAL;  }  if (conn->recvmbox == SYS_MBOX_NULL) {    if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {      return ERR_MEM;    }  }    msg.type = API_MSG_CONNECT;  msg.msg.conn = conn;    msg.msg.msg.bc.ipaddr = addr;  msg.msg.msg.bc.port = port;    api_msg_post(conn->stack, &msg);    sys_mbox_fetch(conn->mbox, NULL);	if (conn->err == ERR_OK)		conn->connected = 1;  return conn->err;}
开发者ID:virtualsquare,项目名称:view-os,代码行数:29,


示例10: netconn_bind

err_tnetconn_bind(struct netconn *conn, struct ip_addr *addr,      u16_t port){	struct api_msg msg;  if (conn == NULL) {    return ERR_VAL;  }  if (conn->type != NETCONN_TCP &&     conn->recvmbox == SYS_MBOX_NULL) {    if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {      return ERR_MEM;    }  }    msg.type = API_MSG_BIND;  msg.msg.conn = conn;  msg.msg.msg.bc.ipaddr = addr;  msg.msg.msg.bc.port = port;    api_msg_post(conn->stack, &msg);    sys_mbox_fetch(conn->mbox, NULL);  return conn->err;}
开发者ID:virtualsquare,项目名称:view-os,代码行数:27,


示例11: xMBPortEventInit

/* ----------------------- Start implementation -----------------------------*/BOOLxMBPortEventInit( void ){    eMailBoxEvent = EV_READY;    xMailBox = sys_mbox_new(  );    return xMailBox != SYS_MBOX_NULL ? TRUE : FALSE;}
开发者ID:BackupTheBerlios,项目名称:freemodbus,代码行数:8,


示例12: tcpip_init

voidtcpip_init(void (* initfunc)(void *), void *arg){  tcpip_init_done = initfunc;  tcpip_init_done_arg = arg;  tcp_mbox = sys_mbox_new();  sys_thread_new(tcpip_thread, NULL, TCPIP_THREAD_PRIO);}
开发者ID:3a1fa340-312c-11e6-8775-0016d322cfd3,项目名称:4b204d7c-312f-11e6-bd79-0016d322cfd3,代码行数:8,


示例13: tcpip_init

/*-----------------------------------------------------------------------------------*/voidtcpip_init(void (* initfunc)(void *), void *arg){  tcpip_init_done = initfunc;  tcpip_init_done_arg = arg;  mbox = sys_mbox_new();  sys_thread_new((void *)tcpip_thread, NULL);}
开发者ID:1573472562,项目名称:netfpga,代码行数:9,


示例14: tcpip_init

/** * Initialize this module: * - initialize all sub modules * - start the tcpip_thread * * @param initfunc a function to call when tcpip_thread is running and finished initializing * @param arg argument to pass to initfunc */voidtcpip_init(void (* initfunc)(void *), void *arg){  lwip_init();  tcpip_init_done = initfunc;  tcpip_init_done_arg = arg;  mbox = sys_mbox_new(TCPIP_MBOX_SIZE);#if LWIP_TCPIP_CORE_LOCKING  lock_tcpip_core = sys_sem_new(1);#endif /* LWIP_TCPIP_CORE_LOCKING */    sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, &stkTcpipThread[TCPIP_THREAD_STACKSIZE - 1], TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);}
开发者ID:racribeiro,项目名称:R2C2-Firmware-OS,代码行数:22,


示例15: pxudp_allocate

static struct pxudp *pxudp_allocate(void){    struct pxudp *pxudp;    err_t error;    pxudp = (struct pxudp *)malloc(sizeof(*pxudp));    if (pxudp == NULL) {        return NULL;    }    pxudp->pmhdl.callback = NULL;    pxudp->pmhdl.data = (void *)pxudp;    pxudp->pmhdl.slot = -1;    pxudp->pcb = NULL;    pxudp->sock = INVALID_SOCKET;    pxudp->df = -1;    pxudp->ttl = -1;    pxudp->tos = -1;    pxudp->count = 0;    pxudp->rp = pollmgr_refptr_create(&pxudp->pmhdl);    if (pxudp->rp == NULL) {        free(pxudp);        return NULL;    }    error = sys_mbox_new(&pxudp->inmbox, 16);    if (error != ERR_OK) {        pollmgr_refptr_unref(pxudp->rp);        free(pxudp);        return NULL;    }#define CALLBACK_MSG(MSG, FUNC)                         /    do {                                                /        pxudp->MSG.type = TCPIP_MSG_CALLBACK_STATIC;    /        pxudp->MSG.sem = NULL;                          /        pxudp->MSG.msg.cb.function = FUNC;              /        pxudp->MSG.msg.cb.ctx = (void *)pxudp;          /    } while (0)    CALLBACK_MSG(msg_delete, pxudp_pcb_delete_pxudp);    CALLBACK_MSG(msg_inbound, pxudp_pcb_write_inbound);    return pxudp;}
开发者ID:gvsurenderreddy,项目名称:virtualbox,代码行数:48,


示例16: tcpip_init

/** * Initialize this module: * - initialize all sub modules * - start the tcpip_thread * * @param initfunc a function to call when tcpip_thread is running and finished initializing * @param arg argument to pass to initfunc */voidtcpip_init(void (* initfunc)(void *), void *arg){#if 0 /* refer lwip_sock_init() called in lwip_init() for details on why this is commented out */  lwip_init();#endif  tcpip_init_done = initfunc;  tcpip_init_done_arg = arg;  mbox = sys_mbox_new(TCPIP_MBOX_SIZE);#if LWIP_TCPIP_CORE_LOCKING  lock_tcpip_core = sys_sem_new(1);#endif /* LWIP_TCPIP_CORE_LOCKING */  sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);}
开发者ID:Malutan,项目名称:TE060X-GigaBee-Reference-Designs,代码行数:24,


示例17: tcpip_init

/** * Initialize this module: * - initialize all sub modules * - start the tcpip_thread * * @param initfunc a function to call when tcpip_thread is running and finished initializing * @param arg argument to pass to initfunc */voidtcpip_init(tcpip_init_done_fn initfunc, void *arg){  lwip_init();  tcpip_init_done = initfunc;  tcpip_init_done_arg = arg;  if(sys_mbox_new(&mbox, TCPIP_MBOX_SIZE) != ERR_OK) {    LWIP_ASSERT("failed to create tcpip_thread mbox", 0);  }#if LWIP_TCPIP_CORE_LOCKING  if(sys_mutex_new(&lock_tcpip_core) != ERR_OK) {    LWIP_ASSERT("failed to create lock_tcpip_core", 0);  }#endif /* LWIP_TCPIP_CORE_LOCKING */  sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);}
开发者ID:duanlv,项目名称:asp-gr_peach_gcc-mbed,代码行数:25,


示例18: tcpip_init

/** * Initialize this module: * - initialize all sub modules * - start the tcpip_thread * * @param initfunc a function to call when tcpip_thread is running and finished initializing * @param arg argument to pass to initfunc */voidtcpip_init(void (* initfunc)(void *), void *arg){  static unsigned char lwipinitflag = 0;  if(lwipinitflag == 0)  {    lwip_init();    tcpip_init_done = initfunc;    tcpip_init_done_arg = arg;    mbox = sys_mbox_new(TCPIP_MBOX_SIZE);#if LWIP_TCPIP_CORE_LOCKING    lock_tcpip_core = sys_sem_new(1);#endif /* LWIP_TCPIP_CORE_LOCKING */    /*----*/    TCPIP_Task_Handle = sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);    lwipinitflag = 1;  }}
开发者ID:ADTL,项目名称:ARMWork,代码行数:26,


示例19: tcpip_init

/** * Initialize this module: * - initialize all sub modules * - start the tcpip_thread * * @param initfunc a function to call when tcpip_thread is running and finished initializing * @param arg argument to pass to initfunc */voidtcpip_init(void (* initfunc)(void *), void *arg){  lwip_init();  tcp_active_pcbs=NULL;  tcp_tw_pcbs=NULL;  tcp_tmp_pcb=NULL;  tcp_listen_pcbs.listen_pcbs=NULL;  tcp_listen_pcbs.pcbs=NULL;  tcpip_init_done = initfunc;  tcpip_init_done_arg = arg;  mbox = sys_mbox_new(TCPIP_MBOX_SIZE);#if LWIP_TCPIP_CORE_LOCKING  lock_tcpip_core = sys_sem_new(1);#endif /* LWIP_TCPIP_CORE_LOCKING */  sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);}
开发者ID:ChenZewei,项目名称:acoral,代码行数:26,


示例20: do_listen

static voiddo_listen(struct api_msg_msg *msg){  if (msg->conn->pcb.tcp != NULL) {    switch (msg->conn->type) {#if LWIP_RAW    case NETCONN_RAW:      LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: listen RAW: cannot listen for RAW./n"));      break;#endif#if LWIP_UDP    case NETCONN_UDPLITE:      /* FALLTHROUGH */    case NETCONN_UDPNOCHKSUM:      /* FALLTHROUGH */    case NETCONN_UDP:      LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: listen UDP: cannot listen for UDP./n"));      break;#endif /* LWIP_UDP */#if LWIP_TCP          case NETCONN_TCP:      msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);      if (msg->conn->pcb.tcp == NULL) {  msg->conn->err = ERR_MEM;      } else {  if (msg->conn->acceptmbox == SYS_MBOX_NULL) {    msg->conn->acceptmbox = sys_mbox_new();    if (msg->conn->acceptmbox == SYS_MBOX_NULL) {      msg->conn->err = ERR_MEM;      break;    }  }  tcp_arg(msg->conn->pcb.tcp, msg->conn);  tcp_accept(msg->conn->pcb.tcp, accept_function);      }#endif    default:      break;    }  }  sys_mbox_post(msg->conn->mbox, NULL);}
开发者ID:AldenHiggins,项目名称:ELEC424-Lab06-Scheduling-with-FreeRTOS,代码行数:42,


示例21: netconn_listen

err_tnetconn_listen(struct netconn *conn){	struct api_msg msg;  if (conn == NULL) {    return ERR_VAL;  }  if (conn->acceptmbox == SYS_MBOX_NULL) {    conn->acceptmbox = sys_mbox_new();    if (conn->acceptmbox == SYS_MBOX_NULL) {      return ERR_MEM;    }  }    msg.type = API_MSG_LISTEN;  msg.msg.conn = conn;    api_msg_post(conn->stack, &msg);    sys_mbox_fetch(conn->mbox, NULL);  return conn->err;}
开发者ID:virtualsquare,项目名称:view-os,代码行数:24,


示例22: netconn_alloc

/** * Create a new netconn (of a specific type) that has a callback function. * The corresponding pcb is NOT created! * * @param t the type of 'connection' to create (@see enum netconn_type) * @param proto the IP protocol for RAW IP pcbs * @param callback a function to call on status changes (RX available, TX'ed) * @return a newly allocated struct netconn or *         NULL on memory error */struct netconn*netconn_alloc(enum netconn_type t, netconn_callback callback){    struct netconn *conn;    int size;    conn = (struct netconn *)memp_malloc(MEMP_NETCONN);    if (conn == NULL) {        return NULL;    }    conn->last_err = ERR_OK;    conn->type = t;    conn->pcb.tcp = NULL;#if (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_UDP_RECVMBOX_SIZE) && /    (DEFAULT_RAW_RECVMBOX_SIZE == DEFAULT_TCP_RECVMBOX_SIZE)    size = DEFAULT_RAW_RECVMBOX_SIZE;#else    switch(NETCONNTYPE_GROUP(t)) {#if LWIP_RAW    case NETCONN_RAW:        size = DEFAULT_RAW_RECVMBOX_SIZE;        break;#endif /* LWIP_RAW */#if LWIP_UDP    case NETCONN_UDP:        size = DEFAULT_UDP_RECVMBOX_SIZE;        break;#endif /* LWIP_UDP */#if LWIP_TCP    case NETCONN_TCP:        size = DEFAULT_TCP_RECVMBOX_SIZE;        break;#endif /* LWIP_TCP */    default:        LWIP_ASSERT("netconn_alloc: undefined netconn_type", 0);        goto free_and_return;    }#endif    if (sys_sem_new(&conn->op_completed, 0) != ERR_OK) {        goto free_and_return;    }    if (sys_mbox_new(&conn->recvmbox, size) != ERR_OK) {        sys_sem_free(&conn->op_completed);        goto free_and_return;    }#if LWIP_TCP    sys_mbox_set_invalid(&conn->acceptmbox);#endif    conn->state        = NETCONN_NONE;#if LWIP_SOCKET    /* initialize socket to -1 since 0 is a valid socket */    conn->socket       = -1;#endif /* LWIP_SOCKET */    conn->callback     = callback;#if LWIP_TCP    conn->current_msg  = NULL;    conn->write_offset = 0;#endif /* LWIP_TCP */#if LWIP_SO_SNDTIMEO    conn->send_timeout = 0;#endif /* LWIP_SO_SNDTIMEO */#if LWIP_SO_RCVTIMEO    conn->recv_timeout = 0;#endif /* LWIP_SO_RCVTIMEO */#if LWIP_SO_RCVBUF    conn->recv_bufsize = RECV_BUFSIZE_DEFAULT;    conn->recv_avail   = 0;#endif /* LWIP_SO_RCVBUF */    conn->flags = 0;    return conn;free_and_return:    memp_free(MEMP_NETCONN, conn);    return NULL;}
开发者ID:comrid1987,项目名称:jb3500,代码行数:88,


示例23: tcpip_init

void tcpip_init(void (* initfunc)(void *), void *arg){  mbox = sys_mbox_new();  //sys_thread_new(tcpip_thread, NULL, TCPIP_THREAD_PRIO);}
开发者ID:GiangND1405,项目名称:ampm_uip_lwip_gprs_freeRTOS,代码行数:5,



注:本文中的sys_mbox_new函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ sys_mbox_post函数代码示例
C++ sys_mbox_free函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。