⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_comms.c

📁 机器人仿真平台,和stage配合运行
💻 C
字号:
/*************************************************************************** * Desc: Tests for the comms device * Author: Andrew Howard * Date: 23 May 2002 # CVS: $Id: test_comms.c,v 1.3.4.2 2003/05/23 21:23:43 inspectorg Exp $ **************************************************************************/#include "test.h"#include "playerc.h"// Basic comms device testint test_comms(playerc_client_t *client, int index){  int i;  char msg[128];  void *rdevice;  playerc_comms_t *comms;  printf("device [comms] index [%d]\n", index);  TEST("changing data mode to PUSH_ALL");  if (playerc_client_datamode(client, PLAYER_DATAMODE_PUSH_ALL) != 0)  {    FAIL();    return -1;  }  PASS();  comms = playerc_comms_create(client, index);  TEST("subscribing (read/write)");  if (playerc_comms_subscribe(comms, PLAYER_ALL_MODE) != 0)  {    FAIL();    return -1;  }  PASS();  for (i = 0; i < 10; i++)  {    TEST1("sending comms message [%d]", i);    snprintf(msg, sizeof(msg), "this is message (%d)", i);    if (playerc_comms_send(comms, msg, strlen(msg) + 1) != 0)      FAIL();    else      PASS();  }  for (i = 0; i < 10; i++)  {    TEST1("reading data (attempt %d)", i);    do      rdevice = playerc_client_read(client);    while (rdevice == client);    if (rdevice == comms)    {      PASS();      if (comms->msg)        printf("recv : %d [%s]\n", comms->msg_len, comms->msg);    }    else      FAIL();  }    TEST("unsubscribing");  if (playerc_comms_unsubscribe(comms) != 0)  {    FAIL();    return -1;  }  PASS();    playerc_comms_destroy(comms);    TEST("changing data mode to PUSH_NEW");  if (playerc_client_datamode(client, PLAYER_DATAMODE_PUSH_NEW) != 0)  {    FAIL();    return -1;  }  PASS();  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -