本文整理汇总了C++中Dynamixel::ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C++ Dynamixel::ReadByte方法的具体用法?C++ Dynamixel::ReadByte怎么用?C++ Dynamixel::ReadByte使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamixel
的用法示例。
在下文中一共展示了Dynamixel::ReadByte方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Read
void Read(int id, int addr, int len)
{
int result = COMM_TXFAIL, error = 0;
int ivalue = 0;
long lvalue = 0;
if(len == 1)
result = DXL.ReadByte(id, addr, &ivalue, &error);
else if(len == 2)
result = DXL.ReadWord(id, addr, &ivalue, &error);
else if(len == 4)
result = DXL.ReadDWord(id, addr, &lvalue, &error);
if(result != COMM_RXSUCCESS)
{
fprintf(stderr, "\n Fail to read! (result : %d) \n\n", result);
return;
}
if(error != 0)
PrintErrorCode(error);
if(len == 1)
fprintf(stderr, "\n READ VALUE : %d \n\n", ivalue);
else if(len == 2)
fprintf(stderr, "\n READ VALUE : (UNSIGNED) %u , (SIGNED) %d \n\n", ivalue, ivalue);
else
fprintf(stderr, "\n READ VALUE : (UNSIGNED) %lu , (SIGNED) %d \n\n", lvalue, lvalue);
}
示例2: Refresh
void Refresh(int id, int addr, int len)
{
int result = COMM_TXFAIL, error = 0;
int ivalue = 0;
long lvalue = 0;
fprintf(stderr, "\n [ESC] : Quit monitoring \n\n");
while(1)
{
if(len == 1)
result = DXL.ReadByte(id, addr, &ivalue, &error);
else if(len == 2)
result = DXL.ReadWord(id, addr, &ivalue, &error);
else if(len == 4)
result = DXL.ReadDWord(id, addr, &lvalue, &error);
if(result != COMM_RXSUCCESS)
{
//fprintf(stderr, "\n Fail to read! (result : %d) \n\n", result);
continue;
}
if(error != 0)
PrintErrorCode(error);
if(len == 1)
fprintf(stderr, " READ VALUE : %.3d [0x%.2X] \r", ivalue, ivalue);
else if(len == 2)
fprintf(stderr, " READ VALUE : %.5d [0x%.2X 0x%.2X] \r", ivalue, DXL_LOBYTE(ivalue), DXL_HIBYTE(ivalue));
else
fprintf(stderr, " READ VALUE : %.10ld [0x%.2X 0x%.2X 0x%.2X 0x%.2X] \r",
lvalue, DXL_LOBYTE(DXL_LOWORD(lvalue)), DXL_HIBYTE(DXL_LOWORD(lvalue)), DXL_LOBYTE(DXL_HIWORD(lvalue)), DXL_HIBYTE(DXL_HIWORD(lvalue)));
if(kbhit())
{
char c = _getch();
if(c == 0x1b)
break;
}
}
fprintf(stderr, "\n\n");
}