You can configure the SLSC chassis by using the web API to create web clients that send HTTP POST requests to the URL of the web server on the SLSC chassis. The web server returns HTTP responses. The body of the HTTP request and response follows the JSON-RPC 2.0 Specification.
The format of the URL of the web server is http://<IP address or hostname of the web server>/nislsc/call. For example, a URL can be http://10.144.160.151/nislsc/call, where 10.144.160.151 is the IP address of the web server. A URL can also be http://SLSC-12001-030FD4DE/nislsc/call, where SLSC-12001-030FD4DE is the hostname of the web server.
The following example shows the body of a request:
{
"id": "1",
"jsonrpc": "2.0",
"method": "initializeSession",
"params":
{
"devices": "SLSC-12001-030898C6-Mod2"
}
}
The following table lists the members in the request. These members follow the JSON-RPC 2.0 specification.
Name | JSON Data Type | Required or Optional | Description |
id | String or Number (integer) | Required | Identifier that the client establishes. |
jsonrpc | String | Required | Version of the JSON-RPC protocol and must be 2.0. |
method | String | Required | Name of the method to invoke. |
params | Object | Optional | Parameter values for the method. You may omit this member only if there are no parameters. |
The following example shows the body of the response without errors:
{
"id": "1",
"jsonrpc": "2.0",
"result":
{
"session_id": "_session99"
}
}
The following examples show the body of the response with errors:
{
"jsonrpc": "2.0",
"id": null,
"error": {
"code": -32700,
"message": "Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. Details: Invalid value. Offset: 148"
}
}
{
"jsonrpc": "2.0",
"id": "1",
"error": {
"code": -32000,
"message": "SLSC error.",
"data": {
"nislsc_code": -250806,
"nislsc_message": "The specified device was not found. Device: SLSC-12001-030898C6-Mod2"
}
}
}
The following tables explain the members in the response. These members follow the JSON-RPC 2.0 specification.
Name | JSON Data Type | Description |
id | String or Number (integer) | Same as the value of the id member in the request. If the JSON format of the request body is invalid, id returns null. |
jsonrpc | String | Version of the JSON-RPC protocol and must be 2.0. |
result | Object | Response from the web server. |
Name | JSON Data Type | Description |
id | String or Number (integer) | Same as the value of the id member in the request. If the JSON format of the request body is invalid, id returns null. |
jsonrpc | String | Version of the JSON-RPC protocol and must be 2.0. |
error | Object | Error that the web server returns. |
The error member includes the following objects:
Name | JSON Data Type | Description |
code | Number (integer) | Number that indicates the error type. |
message | String | Short description of the error. |
data | Object | Additional information about the error. This member also includes two objects: nislsc_code and nislsc_message. nislsc_code is a number that indicates the error code. nislsc_message indicates the description of the error. |
Following the JSON-RPC 2.0 specification, a batch request can send several methods in one request. However, the web server handles batch requests differently from the JSON-RPC 2.0 specification in the following ways:
The following example shows a batch request:
[
{ "id": "2", "jsonrpc": "2.0", "method": "readRegister", "params": { "session_id": "_session0", "register_address": 256 } },
{ "id": "3", "jsonrpc": "2.0", "method": "getProperty:", "params": { "session_id": "_session0", "property": "NI.Debug.Led0Bool" } },
{ "id": "4", "jsonrpc": "2.0", "method": "executeCommand", "params": { "session_id": "_session0", "command": "NI.Debug.EnableLED0Immediate"} }
]
The following example shows the batch response without errors:
[
{ "id": "2", "jsonrpc": "2.0", "result": { "data": 128 } },
{ "id": "3", "jsonrpc": "2.0", "result": { "value": false } },
{ "id": "4", "jsonrpc": "2.0", "result": {} }
]
The following example shows the batch response with errors:
[
{ "id": "2", "jsonrpc": "2.0", "result": { "data": 128 } },
{ "id": "3", "jsonrpc": "2.0", "error": { "code": -32000, "message": "SLSC error", "data": { "nislsc_code": -250893, "nislsc_message": "Chassis power-on hours property write failed." } } },
{ "id": "4", "jsonrpc": "2.0", "error": { "code": -32001, "message": "Error occurred in previous request."} }
]
The following table lists SLSC web API error codes. The JSON-RPC 2.0 specification defines all SLSC web API error codes except -32000 and -32001.
Code | Message | Description |
-32700 | Parse error | The JSON in the request is not valid. |
-32600 | Invalid request | The JSON in the request is not a valid Request object. |
-32601 | Method not found | The method does not exist or is not available. |
-32602 | Invalid params | Invalid method parameters. |
-32603 | Internal error | Internal JSON-RPC error. |
-32001 | SLSC error | An error occurs in the previous request. |
-32000 | SLSC error | SLSC error. |
If the data type of a parameter in an HTTP request is enum, you can specify the parameter with a key or value. The key must be a String and the value must be a Number.
There are two categories of properties in the web API: static properties and dynamic properties. Static properties are defined by the SLSC driver, whereas dynamic properties are defined by the user of the SLSC device. You can find dynamic properties in the SLSC module capabilities. You can use the getDevicePropertyList method to get both static and dynamic properties.
To use the default value of a parameter, you can specify an alias for the parameter, remove the parameter, or specify an empty string for the parameter.
You can specify an alias for the parameter to explicitly use the default value of a member. Aliases are special names that start with a $ sign:
The following example uses an alias to specify the default devices of the session:
{
"id": "4",
"jsonrpc": "2.0",
"method": "connectToDevices",
"params":
{
"session_id": "_session0",
"devices": "$DefaultDevices"
}
}
The following example removes the devices parameter from the request to use the default devices of the session:
{
"id": "4",
"jsonrpc": "2.0",
"method": "connectToDevices",
"params":
{
"session_id": "_session0"
}
}
The following example specifies an empty string for the parameter to use the default devices of the session:
{
"id": "4",
"jsonrpc": "2.0",
"method": "connectToDevices",
"params":
{
"session_id": "_session0",
"devices": ""
}
}
You can use the following methods to manipulate the SLSC chassis and modules:
You can also refer to the attachment for examples of requests and responses, schema files, and default values.
Cancels a method that blocks network communications.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. |
After aborting the session, the session handle remains valid, but methods that access network connections return errors. To recover from an aborted session, close the session and initialize a new one.
The following example shows a request:
{
"id": "3",
"jsonrpc": "2.0",
"method": "abortSession",
"params":
{
"session_id": "_session0"
}
}
The following example shows the response:
{
"id": "3",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Closes an SLSC session.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. |
The following example shows a request:
{
"id": "2",
"jsonrpc": "2.0",
"method": "closeSession",
"params":
{
"session_id": "_session0"
}
}
The following example shows the response:
{
"id": "2",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Connects to an SLSC device.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices.
|
The following example shows a request:
{
"id": "4",
"jsonrpc": "2.0",
"method": "connectToDevices",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
]
}
}
The following example shows the response:
{
"id": "4",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Closes network connections for one or multiple devices.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
If multiple devices share a network connection because they are in the same SLSC chassis, the network connection remains open until the last device is disconnected.
The following example shows a request:
{
"id": "5",
"jsonrpc": "2.0",
"method": "disconnectFromDevices",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
]
}
}
The following example shows the response:
{
"id": "5",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Initializes an SLSC session.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
devices | Optional | String or array of Strings | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. | |
physical_channels | Optional | String or array of Strings | Physical channel names. You can specify one or multiple physical channels. If the data type is String, you can use comma-delimited format to specify physical channels. | |
nvmem_areas | Optional | String or array of Strings | NVMEM area names. You can specify one or multiple NVMEM areas. If the data type is String, you can use comma-delimited format to specify multiple NVMEM areas. | |
access | Optional | Enum | ReadWrite | Access mode to reserve devices. |
reservation_group | Optional | String | "" | Name of the group that allows multiple sessions to simultaneously reserve the same devices. |
reservation_timeout | Optional | Float | 0.0 | Maximum amount of time, in seconds, to wait to reserve a device that has been reserved by other sessions with ReadWrite access. To reserve a device that has been reserved by another session with ReadWrite access, you can close the session, unreserve the device, or use the same reservation group name as that of the device. You can directly reserve a device that has been reserved by another session with ReadOnly access. If reservation_timeout is 0, this method returns an error when a session tries to reserve a module that has been reserved by another session. |
force_reserve | Optional | Boolean | False | Whether to force to close all sessions created by the web server that reserves this resource. |
If reservation_timeout is greater than 0 and access is ReadWrite, a circular waiting may occur when multiple sessions try to reserve multiple devices. The following table shows a circular waiting that occurs when two sessions try to reserve two modules.
Session 1 | Session 2 |
Reserve module 1 | Reserve module 2 |
Try to reserve module 2 | Try to reserve module 1 |
Wait for module 2 | Wait for module 1 |
Both session 1 and session 2 return errors when timeout expires. To avoid the circular waiting, ensure that session 1 and session 2 reserve modules in the same order. If session 1 reserves module 1 first and then reserves module 2, ensure that session 2 also reserves module 1 first and then reserves module 2.
The following table shows the keys and values of the access parameter.
Key | Value |
ReadOnly | 1 |
ReadWrite | 3 |
You can specify only one of the following three parameters in one request: devices, physical_channels, and nvmem_areas. If you do not specify any of the three parameters, this method initializes the session with no resources.
The following table lists the return values.
Return Value | JSON Data Type | Description |
session_id | String | ID of the session. |
The following example shows a request without resources. You can also omit the params member.
{
"id": "1",
"jsonrpc": "2.0",
"method": "initializeSession",
"params": {}
}
The following example shows a request with resources:
{
"id": "1",
"jsonrpc": "2.0",
"method": "initializeSession",
"params":
{
"devices":
[
"SLSC-12001-030898C6-Mod2",
"SLSC-12001-030898C6-Mod3"
],
"access": "ReadWrite",
"reservation_group": "nitest"
}
}
The following example shows the response:
{
"id": "1",
"jsonrpc": "2.0",
"result":
{
"session_id": "_session0"
}
}
Back to Web API Method Reference
Renames a device.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Required | String | Device name. You can specify only one device name. | |
new_device_name | Required | String | New name for the device. |
The following example shows a request:
{
"id": "9",
"jsonrpc": "2.0",
"method": "renameDevice",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6",
"new_device_name": "SLSC-12001-TEST"
}
}
The following example shows the response:
{
"id": "9",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Reserves one or multiple devices to prevent other sessions from accessing the devices. You must reserve a device before using it. To reserve a device that has been reserved by another session with ReadWrite access, you can close the session, unreserve the device, or use the same reservation group name as that of the device. You can directly reserve a device that has been reserved by another session with ReadOnly access.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
access | Optional | Enum | ReadWrite | Access mode to reserve devices. |
reservation_group | Optional | String | "" | Name of the group that allows multiple sessions to simultaneously reserve the same devices. |
reservation_timeout | Optional | Number (float) | 0.0 | Maximum amount of time, in seconds, to wait to reserve a device that has been reserved by other sessions with ReadWrite access. If reservation_timeout is 0, this method returns an error when a session tries to reserve a module that has been reserved by another session. If reservation timeout is -1, reservation timeout uses the value of the Session.ReservationTimeout property. |
The following table shows the keys and values of the access parameter.
Key | Value |
ReadOnly | 1 |
ReadWrite | 3 |
If reservation_timeout is greater than 0 and access is ReadWrite, a circular waiting may occur when multiple sessions try to reserve multiple devices. The following table shows a circular waiting that occurs when two sessions try to reserve two modules.
Session 1 | Session 2 |
Reserve module 1 | Reserve module 2 |
Try to reserve module 2 | Try to reserve module 1 |
Wait for module 2 | Wait for module 1 |
Both session 1 and session 2 return errors when timeout expires. To avoid the circular waiting, ensure that session 1 and session 2 reserve modules in the same order. If session 1 reserves module 1 first and then reserves module 2, ensure that session 2 also reserves module 1 first and then reserves module 2.
The following example shows a request:
{
"id": "6",
"jsonrpc": "2.0",
"method": "reserveDevices",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
],
"access": "ReadWrite",
"reservation_group": "nitest"
}
}
The following example shows the response:
{
"id": "6",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Resets devices to default state. This method sends the specified modules a software reset signal, reinitializes module registers to their initial value, and rereads the module's non-volatile memory. If you specify a chassis, this method resets all modules in the chassis.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
The following example shows a request:
{
"id": "8",
"jsonrpc": "2.0",
"method": "resetDevices",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
]
}
}
The following example shows the response:
{
"id": "8",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Unreserves one or multiple devices so that other sessions can reserve them.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
The following example shows a request:
{
"id": "7",
"jsonrpc": "2.0",
"method": "unreserveDevices",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
]
}
}
The following example shows the response:
{
"id": "7",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Commits properties with pending changes to SLSC hardware. You must commit dynamic properties for the changes to take effect. You do not have to commit static properties because changes take effect immediately after you set static properties. If you set a property multiple times before you commit the property, this method commits only the last value.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
physical_channels | Optional | String or array of Strings | Default physical channels of the session | Physical channel names. You can specify one or multiple physical channels. If the data type is String, you can use comma-delimited format to specify multiple physical channels. |
You can specify only one of the following two parameters in one request: devices and physical_channels. If you do not specify any of the two parameters, the method performs the following operation:
The following example shows a request:
{
"id": "14",
"jsonrpc": "2.0",
"method": "commitProperties",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
]
}
}
The following example shows the response:
{
"id": "14",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Lists all device properties. The following table lists the parameters of this method.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Optional | String | Default device of the session | Device name. You can specify only one device name. |
physical_channel | Optional | String | Default physical channel of the session | Physical channel name. You can specify only one physical channel. |
nvmem_area | Optional | String | Default NVMEM area of the session | NVMEM area name. You can specify only one NVMEM area. |
You can specify only one of the following three parameters in one request: device, physical_channel, and nvmem_area. If you do not specify any of the three parameters, the method performs the following operation:
The following example shows a request with the device parameter:
{
"id": "11",
"jsonrpc": "2.0",
"method": "getDevicePropertyList",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6-Mod1"
}
}
The following example shows the response:
{
"id": "11",
"jsonrpc": "2.0",
"result":
{
"static_properties":
[
"Dev.CapsVersion",
"Dev.Chassis",
"Dev.Commands",
"Dev.Descr",
"Dev.Events",
"Dev.FirmwareVersion",
"Dev.HardwareVersion",
"Dev.Modules",
"Dev.NumSlots",
"Dev.NVMEM.Areas",
"Dev.NVMEM.Size",
"Dev.PhysChans",
"Dev.ProductCategory",
"Dev.ProductName",
"Dev.ProductNum",
"Dev.Properties",
"Dev.SerialNum",
"Dev.SlotNum",
"Dev.TCPIP.EthernetIP",
"Dev.TCPIP.EthernetMAC",
"Dev.TCPIP.Hostname",
"Dev.VendorName",
"Dev.VendorNum"
],
"dynamic_properties":
[
"NI.DateCode",
"NI.Debug.Alphabet",
"NI.Debug.LED0Bool",
"NI.Debug.LED1Bool",
"NI.Debug.LED2Bool"
]
}
}
Back to Web API Method Reference
Gets properties for devices or physical channels.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
physical_channels | Optional | String or array of Strings | Default physical channels of the session | Physical channel names. You can specify one or multiple physical channels. If the data type is String, you can use comma-delimited format to specify multiple physical channels. |
nvmem_areas | Optional | String or array of Strings | Default NVMEM areas of the session. | NVMEM area names. You can specify one or multiple NVMEM areas. If the data type is String, you can use comma-delimited format to specify multiple NVMEM areas. |
property | Required | String | Name of the property. |
You can specify only one of the following two parameters in one request: devices and physical_channels. If you do not specify any of the two parameters, the method performs operations in the following order:
The following table lists the return values.
Return Value | JSON Data Type | Meaning |
data_type | Enum | Data type of the property. |
value | The JSON data type depends on the data type of the property. | Value of the property. |
The following table lists keys and values for the data_type return value.
Key | Value | JSON Data Type |
Bool | 1 | Boolean |
Double | 2 | Number (float) |
Int32 | 3 | Number (integer) |
Int64 | 4 | Number (integer) |
String | 5 | String |
UInt32 | 6 | Number (integer) |
UInt64 | 7 | Number (integer) |
BoolArray | 8 | Array of Booleans |
DoubleArray | 9 | Array of Numbers (float) |
Int32Array | 10 | Array of Numbers (integer) |
Int64Array | 11 | Array of Numbers (integer) |
StringArray | 12 | Array of Strings |
UInt32Array | 13 | Array of Numbers (integer) |
UInt64Array | 14 | Array of Numbers (integer) |
The following example shows a request to get properties from multiple devices:
{
"id": "12",
"jsonrpc": "2.0",
"method": "getProperty",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
],
"property": "NI.DebugLED0"
}
}
The following example shows the response:
{
"id": "12",
"jsonrpc": "2.0",
"result":
{
"data_type": "Bool",
"value":
[
false,
true
]
}
}
The following example shows a request to get properties from multiple physical channels:
{
"id": "12",
"jsonrpc": "2.0",
"method": "getProperty",
"params":
{
"session_id": "_session0",
"physical_channels":
[
"SLSC-12001-030898C6-Mod1/LED0",
"SLSC-12001-030898C6-Mod1/LED1"
],
"property": "NI.ChannelName"
}
}
The following example shows the response:
{
"id": "12",
"jsonrpc": "2.0",
"result":
{
"data_type": "String",
"value":
[
"LED0",
"LED1"
]
}
}
Back to Web API Method Reference
Gets all information of a property.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Optional | String | Default device of the session | Device name. You can specify only one device name. |
physical_channel | Optional | String | Default physical channel of the session | Physical channel name. You can specify only one physical channel. |
nvmem_area | Optional | String | Default physical channel of the session | NVMEM area name. You can specify only one NVMEM area. |
property | Required | String | Name of the property. |
You can specify only one of the following three parameters in one request: device, physical_channel, and nvmem_area. If you do not specify any of the three parameters, the method performs operations in the following order:
The following example shows a request for a static property:
{
"id": "15",
"jsonrpc": "2.0",
"method": "getPropertyInformation",
"params":
{
"session_id": "_session1",
"device": "SLSC-12001-030FD4DE",
"property": "Dev.FirmwareVersion"
}
}
The following example shows the response for the static property:
{
"jsonrpc": "2.0",
"id": "15",
"result": {
"description": "Firmware Version",
"document": "Indicates the firmware version for the device.",
"data_type": "String",
"access": "ReadOnly",
"driver_defined": true,
"pending_changes": false
}
}
The following example shows a request for a dynamic property:
{
"id": "15",
"jsonrpc": "2.0",
"method": "getPropertyInformation",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6-Mod2",
"property": "NI.Debug.LED0Bool"
}
}
The following example shows the response for the dynamic property:
{
"id": "15",
"jsonrpc": "2.0",
"result": {
"description": "One of 4 blue LEDs with Bool data type.",
"documentation": "Towards back of module, under 2 caps, LED on far right",
"unit": "",
"min_value": false,
"max_value": true,
"access": "ReadWrite",
"data_type": "Bool",
"is_enum": false,
"pending_changes": false
}
}
Back to Web API Method Reference
Lists all session properties. The response of this method is static.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. |
The following example shows a request:
{
"id": "10",
"jsonrpc": "2.0",
"method": "getSessionPropertyList",
"params":
{
"session_id": "_session0"
}
}
The following example shows the response:
{
"id": "10",
"jsonrpc": "2.0",
"result":
{
"properties":
[
"Sys.Chassis",
"Sys.DeviceProperties",
"Sys.Devices",
"Sys.Modules",
"Sys.NVMEMAreaProperties",
"Sys.PhysChanProperties",
"Sys.SessionProperties",
"Sys.SystemProperties",
"Session.ConnectedDevices",
"Session.DefaultDevices",
"Session.DefaultNVMEMAreas",
"Session.DefaultPhysChans",
"Session.ReservedDevices"
]
}
}
Back to Web API Method Reference
Sets properties for devices or physical channels. You must commit dynamic properties for the changes to take effect. You do not have to commit static properties. You can set only one property for one or multiple devices or physical channels.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
physical_channels | Optional | String or array of Strings | Default physical channels of the session | Physical channel names. You can specify one or multiple physical channels. If the data type is String, you can use comma-delimited format to specify multiple physical channels. |
property | Required | String | Name of the property. | |
value | Required | The JSON data type depends on the data type of the property. | Value of the property. |
You can specify only one of the following two parameters in one request: devices and physical_channels. If you do not specify any of the two parameters, this method performs operations in the following order:
The following example shows a request:
{
"id": "13",
"jsonrpc": "2.0",
"method": "setProperty",
"params":
{
"session_id": "_session0",
"property": "NI.DebugLED0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
],
"value":
[
true,
false
]
}
}
The following example shows the response:
{
"id": "13",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Executes command on one or more devices or physical channels.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
devices | Optional | String or array of Strings | Default devices of the session | Device names. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
physical_channels | Optional | String or array of Strings | Default physical channels of the session | Physical channel names. You can specify one or multiple physical channels. If the data type is String, you can use comma-delimited format to specify multiple physical channels. |
command | Required | String | Name of command to execute. | |
timeout | Optional | Number (float) | 10.0 | Maximum amount of time, in seconds, to wait for the operation to complete. |
You can specify only one of the following two parameters in one request: devices and physical_channels.
The following example shows a request:
{
"id": "17",
"jsonrpc": "2.0",
"method": "executeCommand",
"params":
{
"session_id": "_session0",
"devices":
[
"SLSC-12001-030898C6-Mod1",
"SLSC-12001-030898C6-Mod2"
],
"command": "NI.EnableLed0Immediate",
"timeout": 10.0
}
}
The following example shows the response:
{
"id": "17",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Gets all information of a command.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Optional | String | Default device of the session | Device name. You can specify only one device name. |
physical_channel | Optional | String | Default physical channel of the session | Physical channel name. You can specify only one physical channel. |
command | Required | String | Name of command. |
You must specify one and only one of the following two parameters in one request: device and physical_channel.
The following example shows a request:
{
"id": "18",
"jsonrpc": "2.0",
"method": "getCommandInformation",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6-Mod2",
"command": "NI.EnableLed0Immediate"
}
}
The following example shows the response:
{
"id": "18",
"jsonrpc": "2.0",
"result": {
"description": "Enable LED 0 and complete immediately.",
"documentation": "Enable LED 0 and complete immediately (doc)."
}
}
Back to Web API Method Reference
Lists all commands of a device or physical channel.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Optional | String | Default device of the session | Device name. You can specify only one device name. |
physical_channel | Optional | String | Default physical channel of the session | Physical channel name. You can specify only one physical channel. |
You can specify only one of the following two parameters in one request: device and physical_channel.
The following example shows a request to get all commands of a device:
{
"id": "16",
"jsonrpc": "2.0",
"method": "getCommandList",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6-Mod1"
]
}
}
The following example shows the response:
{
"id": "16",
"jsonrpc": "2.0",
"result":
{
"commands":
[
"NI.EnableLed0Immediate",
"NI.EnableLed0Delay",
"NI.EnableLed0Poll",
"NI.Event0TimerExpirationInterrupt",
"NI.Event1TimerExpirationInterrupt",
"NI.Event2TimerExpirationInterrupt",
"NI.Event3TimerExpirationInterrupt"
]
}
}
The following example shows a request to get all commands of a physical channel:
{
"id": "16",
"jsonrpc": "2.0",
"method": "getCommandList",
"params":
{
"session_id": "_session0",
"physical_channel": "SLSC-12001-030898C6-Mod1/EventCounter0"
}
}
The following example shows the response:
{
"id": "16",
"jsonrpc": "2.0",
"result":
{
"commands":
[
"NI.EventCounter.Run",
"NI.EventCounter.RunAsync",
"NI.EventCounter.RunAndPoll"
]
}
}
Back to Web API Method Reference
Commits pending changes to hardware for one or multiple NVMEM areas. If you set the same address multiple times before you commit the value, this method only commits the last value.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
nvmem_areas | Optional | String or array of Strings | Default NVMEM areas of the session | NVMEM area name. You can specify one or multiple NVMEM area names. If the data type is String, you can use comma-delimited format to specify multiple NVMEM areas. |
devices | Optional | String or array of Strings | Default devices of the session | Device name. You can specify one or multiple devices. If the data type is String, you can use comma-delimited format to specify multiple devices. |
The following example shows a request:
{
"id": "23",
"jsonrpc": "2.0",
"method": "commitNvmemAreas",
"params":
{
"session_id": "_session0",
"nvmem_areas":
[
"SLSC-12001-030898C6-Mod1/identification",
"SLSC-12001-030898C6-Mod1/capabilities"
]
}
}
The following example shows the response:
{
"id": "23",
"jsonrpc": "2.0",
"result": {}
}
Back to Web API Method Reference
Reads the specific number of bytes starting from the given address within an NVMEM area.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
nvmem_area | Optional | String | Default NVMEM area of the session | NVMEM area name. You can specify only one NVMEM area name. |
address | Required | Number (integer) | Starting address within the NVMEM area to read data. | |
size | Required | Number (integer) | Number of bytes to read from the starting address within the NVMEM area. |
The following table lists the return value of this method.
Return Value | Data Type | Meaning |
next_address | Number (integer) | Starting address plus data size. You can use this value when accessing continuous fields. |
The following example shows a request:
{
"id": "21",
"jsonrpc": "2.0",
"method": "getNvmemBytes",
"params":
{
"session_id": "_session0",
"nvmem_area": "SLSC-12001-030898C6/raw",
"address": 65536,
"size": 16
}
}
The following example shows the response:
{
"id": "21",
"jsonrpc": "2.0",
"result": {
"data": [37, 80, 68, 70, 45, 49, 46, 213, 183, 23, 92, 12, 255, 255, 255, 255],
"next_address": 65537
}
}
Back to Web API Method Reference
Sets the number of bytes of data to write to the given address within an NVMEM area. If you set the same address multiple times before you commit the value, this method only commits the last value. Some areas in the NVMEM of an SLSC module may be protected. You need to specify a serial number and password to write to protected areas. The following table lists the parameters of this method.
Parameter | Required or Optional | JSON Data Type | Default Value | Description | Supported NI-SLSC Version |
session_id | Required | String | ID of the session. | 18.0 or later | |
nvmem_area | Optional | String | Default NVMEM area of the session | NVMEM area name. You can specify only one NVMEM area name. | 18.0 or later |
address | Required | Number (integer) | Starting address within the NVMEM area to read data. | 18.0 or later | |
data | Required | Array of Numbers (8-bit) | Number of bytes to read from the starting address within the NVMEM area. | 18.0 or later | |
password | Optional | String | Empty string | Password of the NVMEM area. Do not specify this input if the NVMEM area is not protected. | 18.5 or later |
serial_number | Optional | String | Empty string | Serial number of the hardware. Do not specify this input if the NVMEM area is not protected. | 18.5 or later |
The following table lists the return value of this method.
Return Value | Data Type | Meaning |
next_address | Number (integer) | Data address plus data size. You can use this value when accessing continuous fields. |
The following example shows a request:
{
"id": "22",
"jsonrpc": "2.0",
"method": "setNvmemBytes",
"params":
{
"session_id": "_session0",
"nvmem_area": "SLSC-12001-030898C6/raw",
"address": 65536,
"data": [37, 80, 68, 70, 45, 49, 46, 82, 93, 23, 92, 12, 255, 255, 255, 255]
}
}
The following example shows the response:
{
"id": "22",
"jsonrpc": "2.0",
"result":
{
"next_address": 65537
}
}
Back to Web API Method Reference
Reads the register of a device.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Optional | String | Default device of the session | Device name. You can specify only one device name. |
address | Required | Number (integer) | Register address. | |
size | Required | Enum | Size of data in bits. |
The following table lists values for the size parameter. The size member does not have keys.
Value | JSON Data Type |
8 | Number (integer) |
16 | Number (integer) |
32 | Number (integer) |
64 | Number (integer) |
The following table lists the return values of this method:
Return Value | Data Type | Meaning |
next_address | Number (integer) | Address of the next register. |
data | Number (integer) | Data of the register. |
The following example shows a request:
{
"id": "19",
"jsonrpc": "2.0",
"method": "readRegister",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6",
"address": 256,
"size": "64"
}
}
The following example shows the response:
{
"id": "19",
"jsonrpc": "2.0",
"result":
{
"next_address": 257,
"data": 1
}
}
Back to Web API Method Reference
Writes data to the register of a device.
Parameter | Required or Optional | JSON Data Type | Default Value | Description |
session_id | Required | String | ID of the session. | |
device | Optional | String | Default device of the session | Device name. You can specify only one device name. |
address | Required | Number (integer) | Register address. | |
size | Required | Enum | Register size in bits. | |
data | Required | Number (integer) | Data to write to the register. |
The following table lists values for the size parameter. The size member does not have keys.
Value | JSON Data Type |
8 | Number (integer) |
16 | Number (integer) |
32 | Number (integer) |
64 | Number (integer) |
The following table lists the return value of this method.
Return Value | Data Type | Meaning |
next_address | Number (integer) | Address of the next register. |
The following example shows a request:
{
"id": "20",
"jsonrpc": "2.0",
"method": "writeRegister",
"params":
{
"session_id": "_session0",
"device": "SLSC-12001-030898C6",
"address": 256,
"size": "64",
"data": 512
}
}
The following example shows the response:
{
"id": "20",
"jsonrpc": "2.0",
"result":
{
"next_address": 257
}
}
You can use the web API with various programming languages to create a web client to configure the SLSC device:
You can also refer to the attachment for the example code.
The following example uses the web API with LabVIEW. The POST VI sends a POST request to the web server. The web server returns the response in the response output.
Back to Using the Web API with Various Programming Languages
The following example uses the web API with Python 2.7. The example sends a POST request to the web server and reads the HTTP response.
# coding = utf-8
# using python 2.7
import urllib2
import json
json_text = '''{
"id": "1",
"jsonrpc": "2.0",
"method": "initializeSession",
"params":
{
"access": "ReadWrite",
"devices": "SLSC-12001-030BE71A",
"force_reserve": true
}
}'''
request = urllib2.Request("http://10.144.160.151/nislsc/call",json_text)
response = urllib2.urlopen(request)
data = json.load(response)
if data.has_key('error'):
if data['error'].has_key('data'):
print(data['error']['data']['nislsc_message'])
else:
print(data['error']['message'])
else:
print("session id = {}".format(data['result']['session_id']))
Back to Using the Web API with Various Programming Languages
HTTP support is not included in the C++ Standard Library. You can use some open-source libraries on github.com to use the web API with C++.
You can refer to the attachment for the example that uses the web API with C++ to send a POST request to the web server and read the HTTP response. The library for HTTP support that the example uses is from the embeddedRest repository at https://github.com/fnc12/embeddedRest.
Back to Using the Web API with Various Programming Languages
You can refer to the attachment for the example that uses the web API with C# to send a POST request to the web server and read the HTTP response.
Back to Using the Web API with Various Programming Languages