====== EMScope JavaScript API ====== JavaScript client library for the EMScope EMI measurement instrument (SW ≥ 4.1). This is the browser counterpart of the Python ''api_v5.py'' client and follows the exact same wire protocol. Refer to the [[public:emscope:websocket_api|WebSocket API]] documentation for the full protocol description. ===== Legacy API — Software ≤ 3.13 ===== The {{ :public:emscope:api.js |api.js}} and {{ :public:emscope:api_example.html |api_example.html}} files are provided for use with EMScope software versions **3.13 and earlier**. Required: a modern browser with native WebSocket support. ===== Current API — Software ≥ 4.1 ===== The {{ :public:emscope:api_v5.js |api_v5.js}} and {{ :public:emscope:api_example_v5.html |api_example_v5.html}} files are provided for EMScope software version **4.1 and later**. Include ''api_v5.js'' in your HTML page. No external dependencies are required for browser use. Under **Node.js**, install the ''ws'' package and pass it via the ''WebSocketImpl'' option (see below). The example file ''api_example_v5.html'' is a self-contained browser application with a live spectrum plot, configuration panel, and message log. Open it directly in a browser after setting the instrument IP address. ==== Connection model ==== Unlike the Python client (which uses an explicit receive loop), the JavaScript client is **event-driven**. The WebSocket connection opens automatically when the object is constructed. All incoming messages are delivered via the callback. ==== RBW / frequency bands ==== ^ Value ^ RBW ^ Frequency range ^ Standard ^ | 200 | 200 Hz | 9 kHz – 150 kHz | CISPR 16-1-1 | | 9 | 9 kHz | 150 kHz – 30 MHz | CISPR 16-1-1 | | 120 | 120 kHz | 30 MHz – 110 MHz | CISPR 16-1-1 | | 1 | 1 kHz | 10 kHz – 150 kHz | MIL-STD-461 | | 10 | 10 kHz | 150 kHz – 30 MHz | MIL-STD-461 | | 200_9 | dual | 9 kHz – 30 MHz | CISPR dual-band | | 1_10 | dual | 10 kHz – 30 MHz | MIL dual-band | ==== Node.js ==== The library is compatible with Node.js. Install the **ws** package and pass it as the WebSocket implementation via the constructor options. See the source file for details.