From c26a3f7408d48cb36d19e5c0f7203c42781afe48 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 1 Sep 2026 22:46:59 -0500 Subject: [PATCH 1/7] feat(canopen): add DS402 drive panel web app (in-browser SDO over the CAN bridge) A single-file, offline, dependency-free browser front-end that commissions a CANopen CiA 402 (DS402) drive through the existing USB<->CAN bridge (can_bridge_example). It reuses the CAN console's transport + stream_frame framing to move raw CAN frames and layers all CANopen/DS402 logic in the browser ("architecture option A") - the firmware stays a dumb raw-CAN pipe, no firmware change needed. Includes: - An in-browser CANopen SDO client: expedited + segmented upload (read) and download (write) on the default SDO channel (0x600/0x580 + nodeId), with abort decoding and one-transaction-at-a-time serialization. - A DS402 panel: statusword (0x6041) -> power-drive-system state decode, controlword (0x6040) command buttons + enable sequence / quick-stop / fault-reset, mode of operation (0x6060/0x6061), target and actual velocity/position/torque, and an opt-in live poll. - Node identity (0x1000/0x1008/0x1018) and NMT controls. - A generic object-dictionary panel to read/write ANY index:subindex with a chosen data type (u8..i32/string/raw hex), for vendor-specific objects. Because it drives the node over SDO (not cyclic PDOs) it is a commissioning / bring-up tool; the bus must be in Normal mode so the bridge ACKs the node. The apps index auto-lists it from its /<meta description>; canopen.rst links it next to the CAN console. Verified: node --check clean, and a runtime test of the SDO expedited/segmented up/download codec + DS402 state decode against a mock CANopen server (13/13 round-trips). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --- components/canopen/web/ds402_panel.html | 1292 +++++++++++++++++++++++ doc/en/buses/canopen.rst | 12 + 2 files changed, 1304 insertions(+) create mode 100644 components/canopen/web/ds402_panel.html diff --git a/components/canopen/web/ds402_panel.html b/components/canopen/web/ds402_panel.html new file mode 100644 index 000000000..4fa96c25c --- /dev/null +++ b/components/canopen/web/ds402_panel.html @@ -0,0 +1,1292 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <title>espp DS402 Drive Panel (WebUSB / Web Serial) + + + + + +
+
+

espp DS402 Drive Panel (WebUSB / Web Serial)

+ Disconnected +
+ +
+ This browser supports neither WebUSB nor Web Serial. Use a Chromium-based + browser (Chrome / Edge / Opera) on a secure origin (https, localhost or file://). +
+ + +
+

Device

+
+ + + + +
+

Not connected. WebUSB default filter: VID 0x1209 / PID 0x0d32 (espp default); the vendor (0xFF) interface is discovered from the descriptors at runtime.

+
+ + +
+

CAN bus

+
+
+ Baud rate + +
+
+ Mode + +
+
+ Node ID (1–127) + +
+
+ + + +
+
+ Bus: unknown + Baud: - + Mode: - + RX: 0 + TX: 0 + Err: 0 +
+
+ NMT: + + + + + +
+
+ + +
+

Node identity

+
+ + Objects 0x1000 / 0x1008 / 0x1018 via SDO. +
+
+ Device type (0x1000)- + Device name (0x1008)- + Vendor ID (0x1018:1)- + Product code (0x1018:2)- + Revision (0x1018:3)- + Serial number (0x1018:4)- +
+
+ + +
+

DS402 drive control

+
+ State (0x6041): + unknown + statusword - +
+ + +
+
+ +
+
+ Controlword (0x6040): + + + + + + +
+
+
+ Raw controlword (hex) + +
+ +
+
+ Mode of operation (0x6060) + +
+ + display (0x6061): - +
+ +
+
+
+ Target velocity (0x60FF, i32) + +
+ +
+ Target position (0x607A, i32) + +
+ +
+ Target torque (0x6071, i16) + +
+ +
+
+ Pos actual (0x6064): - + Vel actual (0x606C): - + Torque actual (0x6077): - +
+
+ + +
+

Object dictionary access (vendor-specific)

+
+
+ Index (hex) + +
+
+ Subindex + +
+
+ Type + +
+
+ Value (for write) + +
+ + +
+

 

+
+ + +
+

Log + + +

+
+
+ +
+ espp DS402 Drive Panel · talks to the espp USB<->CAN bridge + (components/canopen/can_bridge_example) · all + CANopen/DS402 logic runs in the browser over raw CAN (option A). Single-file, + offline, no dependencies. +
+
+ + + + diff --git a/doc/en/buses/canopen.rst b/doc/en/buses/canopen.rst index c54977f11..d33a685ba 100644 --- a/doc/en/buses/canopen.rst +++ b/doc/en/buses/canopen.rst @@ -46,6 +46,18 @@ an :doc:`../dispatcher/index` (module id 5), so the hosted send frames (as a bus master) and inspect the bus (streaming every received frame, optionally in passive listen-only mode) directly from a Chromium browser. +For CiA 402 (DS402) drives there is also a purpose-built +`DS402 drive panel `_ web +app that talks to the *same* bridge. It layers a CANopen SDO client and the DS402 +profile entirely in the browser (the firmware stays a dumb raw-CAN pipe): read +the node identity, walk the power-drive-system state machine (statusword / +controlword with the enable sequence, quick-stop and fault-reset), select the +mode of operation, set target and read actual velocity/position/torque, and +read/write any object dictionary index:subindex (including vendor-specific +objects) with a chosen data type. Because it drives the node over SDO rather than +cyclic PDOs it is a commissioning / bring-up tool; the bus must be in Normal +(not listen-only) mode so the bridge ACKs the node. + .. ---------------------------- API Reference ---------------------------------- API Reference From 4a745c49bad1a816269051000cb07b8a2dad4859 Mon Sep 17 00:00:00 2001 From: William Emfinger Date: Tue, 1 Sep 2026 23:02:06 -0500 Subject: [PATCH 2/7] fix(canopen): escape invalid < in ds402_panel meta description The content had a literal "USB<->CAN"; an unescaped < makes the tag invalid HTML. Reword to "USB-to-CAN" (same fix as can_console). Co-Authored-By: Claude Opus 4.8 (1M context) --- components/canopen/web/ds402_panel.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/canopen/web/ds402_panel.html b/components/canopen/web/ds402_panel.html index 4fa96c25c..0fd0b828f 100644 --- a/components/canopen/web/ds402_panel.html +++ b/components/canopen/web/ds402_panel.html @@ -4,7 +4,7 @@ espp DS402 Drive Panel (WebUSB / Web Serial) - +