Перейти до вмісту

Appendix F: Web Interfaces

Цей контент ще не доступний вашою мовою.

To access the device using a browser, the EM-486 expects an Ethernet connection to port 80 and HTTP transmissions. To connect in the address bar of the browser, call the IP address of the device (to display the address on the EM-486 display, see section 5.3.1 of the manual). The browser displays WEB pages that allow you to read the status of the device, set parameters, call MODBUS functions and perform file operations on the memory card.

In addition, the HTTP connection can be used by other applications to automatically invoke MODBUS functions using the API.

EM-486 supports API in two formats: JSON and XML. For example, if the IP address of the device is “192.168.0.111”, then the API JSON request without parameters will look like 192.168.0.111/api.json, and the XML API will look like 192.168.0.111/api.xml (further in the examples, each request begins with one of these lines, and this beginning is referred to as <API call>).

An example of a response to a request is given below.

JSON format:

{
"type": "EM-48x API",
"version": "1.1",
"device": "EM-486",
"firmwareVersion": 43,
"loginChallenge": "92uJzC89fQEdB62JxOW75sGtNAmA"
}

XML format:

<ApiReply>
<Type>EM-48x API</Type>
<Version>1.1</Version>
<Device>EM-486</Device>
<FirmwareVersion>43</FirmwareVersion>
<LoginChallenge>92uJzC89fQEdB62JxOW75sGtNAmA</LoginChallenge>
</ApiReply>
JSONXMLDescription
(unnamed)ApiReplyRoot element of the response
typeTypeResponse type (always “EM-48x API”)
versionVersionAnswer version
deviceDeviceDevice
firmwareVersionFirmwareVersionFirmware version
loginChallengeLoginChallengeSecure authorization offer (see below)

To access MODBUS authorization is required, which can be done in two ways:

  1. The unprotected password by sending an API request with a password string in the plainpass parameter;
  2. With SHA-1 protection using the authorization proposal received in the loginChallenge field. To do this, compute the standard SHA-1 hash of the string composed of the authorization clause and password, and then send an API request with the hash string (encoded in hexadecimal or BASE-64) in the lcanswer parameter. For example, for the factory password EM-486 “11111” and the sentence in the example above, the hash of the compound string “92uJzC89fQEdB62JxOW75sGtNAmA11111” in hexadecimal form is “28457e7fc55a67bf59caf5f73e42fd168a5fe6a3”.

Upon successful authorization, the device returns a response with a redirection to the session page, for example, /1c193447/api.xml (hereinafter in the examples <API session call>), where “1c193447” is the temporary session code. If the application making the request does not support redirection, then the requests should be called with the redirects parameter set to “0”.

The response to the request <API call>?lcanswer=28457e7fc55a67bf59caf5f73e42fd168a5fe6a3&redirects=0 if it was sent after the response above:

JSON format:

{
"session": "1c193447",
"status": "Ready"
}

XML format:

<ApiReply>
<Session>1c193447</Session>
<Status>Ready</Status>
</ApiReply>
JSONXMLDescription
sessionSessionSession code. The absence of this element means that authorization is required. Authorized requests begin with <API session call> with the specified code.
statusStatusMODBUS call status: “Busy” - busy, a MODBUS call is being processed. The call should be repeated without parameters to get the result or to send a new call; “Ready” - ready, a new MODBUS call can be sent.

To call MODBUS, the following parameters are used:

ParameterRange of ValuesDescription
mbc_uid0–255Destination device ID
mbc_func1–6, 15–16MODBUS function code. Only one value can be written for write functions, including multiple write functions (codes 15 and 16)
mbc_addr0–65535Register, flag or digital input address
mbc_data0–65535For read functions - the number of read values (from 1 to 16). For write functions, the value to be written
dosend0–65535The presence of this parameter with any value in the request makes a MODBUS call with the specified parameters

The answer to <API session call>?mbc_uid=111&mbc_func=3&mbc_addr=213&mbc_data=3&dosend=1 (for the value of the EM-486 own identifier equal to the factory default “111”) - reading the current time:

JSON format:

{
"type": "EM-48x API",
"status": "Ready",
"MODBUSQueries": [
{
"deviceID": 111,
"function": 3,
"address": 213,
"data": 3,
"response": {
"data": [12, 38, 25]
}
}
]
}

XML format:

<ApiReply>
<Type>EM-48x API</Type>
<Status>Ready</Status>
<MODBUSQuery>
<UnitID>111</UnitID>
<Function>3</Function>
<Address>213</Address>
<Data>3</Data>
<Response>
<Data>12</Data>
<Data>38</Data>
<Data>25</Data>
</Response>
</MODBUSQuery>
</ApiReply>
JSONXMLDescription
MODBUSQueriesMODBUSQueryMODBUS request
unitIDUnitIDDestination device identifier in the request
functionFunctionMODBUS function code in request
addressAddressAddress of register, flag or discrete input in request
responseResponseReply to request
dataDataIn a request - the number of read values or a written value, in a response - read or written data
JSONXMLDescription
errorInQueryErrorInQueryMODBUS request error (field in request instead of response field): “Query device ID illegal” - invalid device ID; “Query address illegal” - invalid address; “Query data illegal” - an invalid value
errorInResponseErrorInResponseMODBUS response error (field in request instead of response field): “Response mismatch” - The accepted response does not match the request
exceptionCodeExceptionCodeMODBUS exception code (field in response instead of data field)
exceptionExceptionException MODBUS (field in response instead of data field, values are listed in table 5.2 of the manual)