Overview
The WUJI Hand 2 keeps a log ring buffer in flash.export_flash_logs() pulls the whole ring, decodes it frame by frame, and writes a JSONL file with one log entry per line.
When something goes wrong on the device, this is the primary evidence. It records events from the firmware’s point of view, which sits closer to the fault than host-side SDK logs.
Matching examples: examples/python/wuji_hand_2/5.export_flash_logs.py and examples/c/wuji_hand_2/5_export_flash_logs.c.
For API and field definitions, see Diagnostics and Logs.
This example only reads. It doesn’t enable the motors, and the fingers don’t move.
Prerequisites
Hardware
Software
Data Flow
Every call exports everything and writes a new file. There’s no API to ask how many entries exist first, and no incremental export.Where Output Goes
out_dir defaults to None, writing to the SDK’s default directory ~/.wuji/logs alongside the SDK’s own logs, with a flash_ prefix on the filename:
out_dir to write elsewhere.
Fields per Line
Integration Steps
1. Discover and Connect to the Target Device
In Python, filterscan() results for DeviceType.WujiHand2, confirm that a match exists, then call connect(sn=...). In C, initialize the SDK, filter wuji_scan_devices() results for WUJI_DEVICE_TYPE_WUJI_HAND_2, then connect by serial number with wuji_connect(). Export doesn’t require enabling the motors.
2. Export Logs and Get the Result
One call exports all logs and returns the file path and frame count. PassNone in Python or NULL in C to use the SDK’s default directory.
- Python
- C
result only after a successful export. On failure, the output isn’t populated. Read the error and enter device cleanup.
3. Check the File and Disconnect
When the frame count is nonzero, the Python example reads and parses the first JSONL line. The C example prints the path and frame count. Use that path to read the file in the application.manager.disconnect_all() in finally. C calls wuji_dev_disconnect(dev), wuji_dev_release(dev), and wuji_shutdown() in order.
Running It
- Python
- C
Measurements
On a right-hand WUJI Hand 2:
What the export contained:
Most of it is periodic status lines from
sboard_app shaped like [B2] T:25 R:20 g:0 bc:0/0 ..., plus node heartbeats such as nodes 4/5: [1:hb=0 2:hb=0 ...]. When investigating, filter by level for Warn and above first, then narrow by target to a module.
Notes
Adapting It
Filter for What You Care About
Each JSONL line stands alone, sojq filters directly:
Export to a Specific Directory
out_dir argument. The default lands in ~/.wuji/logs mixed in with the SDK’s own logs, distinguished by the flash_ prefix.
How This Relates to Host-Side SDK Logs
The two have different vantage points. Flash logs are the firmware’s view, recording the bus, node heartbeats, and server state. SDK logs sit in the same directory and record host-side connect, subscribe, and publish activity. For connection problems, compare timestamps across both.Don’t Export During Control
Don’t export Flash logs during control, even from another thread or process. Disable the device and stop sending control commands before export. Wait for the export function to return and confirm that all concurrent exports for the device have finished before enabling the device and resuming control. See Flash Log Export Precautions. A full export reads the entire ring buffer, measured at about 3 seconds for a thousand-odd entries. During export, device status feedback slows down and drops frames. For continuous monitoring, subscribe tojoint_diagnostics.
Related
- Subscribing With Callbacks: how to get live diagnostic data
- Troubleshooting: common problems and how to locate them in logs