EEZ Studio InstrumentWrite Line Endings: Trace the Connection Before Adding a Terminator

An EEZ Studio InstrumentWrite string is not necessarily the final string queued for the transport. The instrument connection layer can append a line ending after the Flow action passes its Data value onward. Adding a terminator in the Flow expression without checking that layer can produce two terminators.

The InstrumentWrite reference describes the instrument and Data properties. The action source, renderer connection and main connection establish the path examined here, pinned to EEZ Studio v0.29.0 commit 3000161d09d40a5c1dc2477ddc30b38037b3a612.

This article traces string construction. It does not report bytes captured from an instrument or claim that a generic test word is a valid command for a particular device.

InstrumentWrite delegates a string command

The action validates the instrument reference and rejects Data when it is not a string. It obtains the instrument's connection, acquires it, awaits connection.command(data) and releases the connection through a finally block around the command operation.

In the renderer connection, command delegates to send. This is a command path, not a raw binary-byte API implied by the word “write.” Passing a blob does not bypass line-ending handling; the action's string check rejects that representation earlier.

Follow the main connection's send method before deciding which suffix belongs in Data. The command's protocol and configured line ending are part of the actual construction path.

On the SCPI branch, PING becomes PING followed by one newline, while an already terminated PING receives a second newline in the queued string.
Original source-derived engineering concept diagram. Examples are hypothetical; no table, chart, embedded Dashboard or instrument operation was executed.

The connection appends according to protocol

Once the connection-state and active-operation checks admit the send, an instrument whose commandsProtocol is SCPI has command plus a newline character queued by the inspected method. For other protocols, it queues command plus the configured COMMAND_LINE_ENDING value, falling back to an empty string when that lookup does not provide a value.

The mapping contains no ending, newline, carriage return and the two-character carriage-return/newline sequence. The internal setting name “both-nl-and-cr” maps to \r\n; read the value rather than inferring byte order from the name.

These branches append a suffix. The shown construction does not first remove an identical suffix already present in the supplied command.

For a purely local illustrative string, Data equal to PING on the SCPI branch produces a queued PING\n. Data already equal to PING\n produces queued PING\n\n. These are source-derived queue strings, not measured wire transactions and not instructions to send PING to equipment.

Inspect escaped content, not only terminal appearance

A proposed adapter fixture should intercept the queue entry in a local mock before transport. Record the original Data string, the configured protocol, the line-ending setting and the resulting queued string using escaped notation or character codes.

Compare an unterminated input with one already containing a newline. Then, on the non-SCPI branch, compare the supported no-ending and carriage-return/newline settings. Keep the test disconnected from real equipment; string construction can be established without issuing a device command.

A terminal display is poor evidence for this boundary because control characters may move the cursor or create visually similar blank space. The relevant distinction is the constructed character sequence. Any later transport encoding or batching requires its own observation.

Put terminator ownership in one place

Choose whether the connection configuration or an application-specific path supplies the required suffix, based on the actual protocol and supported APIs. Do not globally strip every trailing newline from arbitrary strings as a substitute for that contract; content and command framing have different meanings in different protocols.

For the inspected SCPI branch, account for the appended newline when building the Data expression. For a non-SCPI instrument, review the actual commandLineEnding configuration instead of assuming the same rule applies.

An awaited command call also should not be described as proof that a device completed a physical operation. This article establishes the string handed into the send queue, not a correlated device response or an execution-complete acknowledgement.

No connection, device command or transport experiment was run. The practical result is a short path to audit when an instrument appears to receive an extra blank command: inspect Data, then the connection's protocol-dependent suffix, before changing the payload producer or blaming the device parser.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *