Digilent Instrumentation Protocol
The Digilent Instrumentation Protocol is a JSON encoded command set for communicating with and controlling electronic instruments. The Digilent Instrumentation Protocol was initially designed as the communication protocol between WaveForms Live and and the OpenScope MZ, however the protocol is designed to be hardware agnostic and extensible.
JSON encoding offers several advantages including ease of use in JavaScript based web and mobile applications, human readable commands, and bus agnostic communication that easily supports HTTP, UART, TCP, WebSockets and more.
Command Format
- The JSON data below is expanded for readability. All JSON should be minified (white space removed) before transmission.
- Unless otherwise noted all commands are sent using the POST method when using HTTP.
- All Digilent Instrumentation Protocol commands must be a JSON object or a chunked transfer:
- JSON Object
- Must start with a '{' character and ends with a '}' character.
- May be followed by one or more '\r\n'.
- Chunked Transfer
- Composed of one or more chunks.
- Each chunk must begin with the number of bytes in the chunk in ASCII hexidecimal format followed by one '\r\n', the binary data, and one '\r\n'.
- The chunk length does not include the '\r\n' between the chunk length and the data.
- The chunk length does not include the trailing '\r\n' after the binary data.
- Each chunked transfer is terminated with a zero length chunk.
- Ex. <code> 6\r\n chunk1\r\n 8\r\n somedata\r\n E\r\n in\r\n\r\nchunks.\r\n 0\r\n \r\n </code>
Multi Command
Multiple commands can be sent in a single transaction using a multicommand.
Example:
Command
{ "dc":{ "1":[ { "command":"setVoltage", "voltage":3300 }, { "command":"getVoltage" } ], "2":[ { "command":"setVoltage", "voltage":5000 } ] } }
Response
{ "dc":{ "1":[ { "command":"setVoltage", "statusCode":0, "wait":500 }, { "command":"getVoltage", "statusCode":0, "wait":100, "voltage":3300 } ], "2":[ { "command":"setVoltage", "statusCode":0, "wait":500 } ] } }