> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wuji.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# 设备参数与操作

## handedness（GET）

获取**左右手识别**结果（left / right）。

```python theme={null}
side = hand.handedness().get()   # → "left" 或 "right"
```

## ip（SET/GET）

**读写设备静态 IP 地址**。`set` 把新 IP 写入设备 flash，固件不会热切换正在运行的以太网栈，新 IP 下次重启才生效。`set` 之后、重启之前，`get` 仍返回当前生效的 IP。

```python theme={null}
hand.ip().get()                    # 读当前 IP，如 "192.168.1.110"
hand.ip().set("192.168.1.201")     # 写入 flash，重启后生效
```

IP 在同网段内必须唯一，避开其他设备与电脑网卡。

修改 IP 分四步：`set` 写入新地址、`reboot` 重启设备、按新 IP 重连、`get` 确认。

```python theme={null}
hand.ip().set("192.168.1.201")
hand.reboot()
manager.disconnect_all()
# 等设备重启且以太网就绪，约 8 秒
hand = manager.connect(address="192.168.1.201:50001", device_name="wuji_hand_2")
hand.ip().get()                    # → "192.168.1.201"
```

> [!WARNING]
>
> 新 IP 重启后才生效。`set` 只写入 flash，不改变正在运行的连接。重启前 `get` 返回的仍是当前 IP。

## reboot（EXEC）

**重启设备**。设备会断连，重启后需重新连接。常与 `ip().set()` 搭配，让写入 flash 的新 IP 生效。

```python theme={null}
hand.reboot()
```

## 使能 / 失能 / 急停

```python theme={null}
hand.enable()               # 使能全部关节
hand.disable()              # 失能全部关节
hand.enable(joints=mask)    # 可选：长度 20 的 0/1 掩码，作用于掩码位为 1 的关节
hand.emergency_stop()       # 急停：整手动作，不接受掩码
```

## clear\_fault（EXEC）

**清除故障**：直接动作，无参数时作用于整手。

```python theme={null}
hand.clear_fault()                  # 清除全部关节故障
hand.clear_fault(joints=mask)       # 可选：长度 20 的 0/1 掩码，只清除掩码位为 1 的关节
```

> [tab] Python
>
> Python：本页前文已展示 Python 接口。

> [tab] C
>
> C 侧接口与本页 Python 接口语义一致，函数前缀 `wuji_hand_2_`。初始化约定、内存管理、错误码与工程构建见 [C 接口参考](https://docs.wuji.tech/docs/zh/wuji-sdk/latest/data-reference.md)。
>
> ### 控制动作（含 20 关节掩码）
>
> `enable / disable / clear_fault / set_origin / clear_origin` 接受可选掩码 `const uint8_t mask[20]`，传 `NULL` 表示对全部关节触发。`emergency_stop` 仅作用于整手、不接受掩码：
>
> ```c theme={null}
> // 整手使能
> wuji_hand_2_enable(dev, NULL);
> // 整手清错
> wuji_hand_2_clear_fault(dev, NULL);
>
> // 仅食指 4 关节（flat 索引 4..7）
> uint8_t mask[20] = {0};
> for (int i = 4; i < 8; i++) mask[i] = 1;
> wuji_hand_2_enable(dev, mask);            // 仅使能食指 4 关节
> wuji_hand_2_clear_fault(dev, mask);       // 仅清食指 4 关节的故障
>
> // 整手紧急停止
> wuji_hand_2_emergency_stop(dev);
>
> // 用户零点
> wuji_hand_2_set_origin(dev, NULL);
> wuji_hand_2_clear_origin(dev, NULL);
> ```
>
> ### 身份与诊断
>
> ```c theme={null}
> WujiHandedness side;
> wuji_hand_2_get_handedness(dev, &side);   // WUJI_HANDEDNESS_LEFT / _RIGHT
>
> uint8_t n_online;
> wuji_hand_2_online_joints_count(dev, &n_online);  // 0..20
>
> // 字符串两步查询：先用 buf=NULL,buf_len=0 探出所需长度
> size_t needed = 0;
> wuji_hand_2_get_ip(dev, NULL, 0, &needed);
> char* ip = malloc(needed);
> wuji_hand_2_get_ip(dev, ip, needed, NULL);
> printf("ip=%s\n", ip);
> free(ip);
> ```
>
> 写入 IP 用 `wuji_hand_2_set_ip(dev, "192.168.1.201")`，重启设备用 `wuji_hand_2_reboot(dev)`，生效时机与 Python 一致。
>
> `get_hw_version` / `get_comm_diag` 返回的 `out` 持有堆字段，使用后需调对应 `_free` 释放（仅在返回 `WUJI_STATUS_OK` 时）。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.